vtran@cod.NOSC.MIL (Viet D. Tran) (03/21/91)
I have programs that were written in two different languages, Pascal and C. Now, I am having trouble combining them together, or linking them in the compiling process (using either Pascal or C compiler) to make only one executable file. If anyone knows how to do mixed language programs with Pascal and C (such as C and In Line Assembly), or has any other suggestions, please let me know. Thanks.
sjs@gnv.ifas.ufl.edu (03/22/91)
In article <2941@cod.NOSC.MIL>, vtran@cod.NOSC.MIL (Viet D. Tran) writes: > > I have programs that were written in two different languages, Pascal > and C. Now, I am having trouble combining them together, or linking > them in the compiling process (using either Pascal or C compiler) to > make only one executable file. If anyone knows how to do mixed language > programs with Pascal and C (such as C and In Line Assembly), or has any > other suggestions, please let me know. Thanks. I have no trouble doing this with Microsoft C and Pascal. Just make sure there is only one main program; all the other routine files must be sub- procedures or sub-functions. Also make sure that they are compiled to the same size (compact, small, large, etc.). You left out a lot of info (compilers, op systems, etc.). Try a small program (like MAIN.PAS and a called SUB_FUNC.C) and see what happens. +---------------------------------------------+------------------------------+ | ~~~ Sid Sachs | "Time to wake up! | | / \ ~~~ at the Mountains of Madness | Time to rise!" | | / / \ | | | / / \ Bitnet: sjs@ifasgnv | - Silver Lady, | | / \ Internet: sjs@gnv.ifas.ufl.edu | Intergalactic Touring Band | +---------------------------------------------+------------------------------+
ts@uwasa.fi (Timo Salmi) (03/22/91)
In article <2941@cod.NOSC.MIL> vtran@cod.NOSC.MIL (Viet D. Tran) writes: > >I have programs that were written in two different languages, Pascal >and C. Now, I am having trouble combining them together, or linking See Olhsen & Stoker, Turbo Pascal Advanced Techniques, Que, 1989. ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
bigelow@hpfcso.FC.HP.COM (Jim Bigelow) (03/22/91)
>programs with Pascal and C (such as C and In Line Assembly), or has any >other suggestions, please let me know. Thanks. ---------- You don't mention what hardware plateform, and which laguage vendor, sun, borland, green hills, HP. If you'r using C and Pascal on HP9000 Series 300 workstation, I can give you very specific advice on how to get C and Pascal to work together. Best regards, Jim Bigelow Colorado Language Lab. HP
bobb@vice.ICO.TEK.COM (Bob Beauchaine) (03/23/91)
In article <1991Mar21.115923.88@gnv.ifas.ufl.edu> sjs@gnv.ifas.ufl.edu writes: > >I have no trouble doing this with Microsoft C and Pascal. Just make sure >there is only one main program; all the other routine files must be sub- Don't forget the other fine details, like making sure all of the C functions use the Pascal calling convention, and that you don't call any C library routines, and that you don't have any global static declared data in the C routine (unless you've got Turbo 6.0) and... /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Bob Beauchaine bobb@vice.ICO.TEK.COM C: The language that combines the power of assembly language with the flexibility of assembly language.
seth@wet.UUCP (Seth Olitzky) (03/30/91)
In article <2941@cod.NOSC.MIL> vtran@cod.NOSC.MIL (Viet D. Tran) writes: > >I have programs that were written in two different languages, Pascal >and C. Now, I am having trouble combining them together, or linking >them in the compiling process (using either Pascal or C compiler) to >make only one executable file. If anyone knows how to do mixed language >programs with Pascal and C (such as C and In Line Assembly), or has any >other suggestions, please let me know. Thanks. A lot depends on what compilers and target machine you are using. Borland pascal TPU are not compatible with Borland C objects. You will need to have two compilers from the same vendor such as the Microsoft C and Pascal compiler or possible the Jensen (JPI) family of compilers. Be very careful when using library calls as this can pull in lots of stuff. The problem with mixing code is that you might pull in identical functions from two different libraries and create an unnecessarily large program. . -- ----------------------------------------------------------------------------- Seth Olitzky seth@wet ...!sun!hoptoad!wet!seth ----------------------------------------------------------------------------
amead@s.psych.uiuc.edu (alan mead) (04/06/91)
seth@wet.UUCP (Seth Olitzky) writes: >In article <2941@cod.NOSC.MIL> vtran@cod.NOSC.MIL (Viet D. Tran) writes: >> >>I have programs that were written in two different languages, Pascal >>and C. Now, I am having trouble combining them together, or linking >>... >A lot depends on what compilers and target machine you are using. Borland >pascal TPU are not compatible with Borland C objects. You will need to >... Actually, I think any .OBJ file can be linked to Turbo Pascal (probably most other popular compilers as well). The problem is whether or not pascal can use the code. The answer is usually yes--Ohlsen and Stoker have a longish chapter on linking C with Turbo Pascal in _Advanced Techniques in Turbo Pascal_ (<- that's only an approximate title :( *But*, the one of the first lines says approximately: "Avoid using any Standard C function calls or else you'll need to buy the Run Time Library in order to get the OBJ file to link to Pascal." Which would seem to limit the practical possibilities. So, I've never done this. I don't know how much of a hassle it turns out to be. Sadly, I know of no Pascal compiler that compiles to .OBJ format; as a result, you cannot link Pascal code into other languages. -alan mead : amead@s.psych.uiuc.edu
bobb@vice.ICO.TEK.COM (Bob Beauchaine) (04/06/91)
In article <1991Apr5.211211.24087@ux1.cso.uiuc.edu> amead@s.psych.uiuc.edu (alan mead) writes: >seth@wet.UUCP (Seth Olitzky) writes: > > >Actually, I think any .OBJ file can be linked to Turbo Pascal (probably >most other popular compilers as well). The problem is whether or not >pascal can use the code. > >The answer is usually yes--Ohlsen and Stoker have a longish chapter on >linking C with Turbo Pascal in _Advanced Techniques in Turbo Pascal_ >(<- that's only an approximate title :( > Well, as someone who *has* done this in the past, I have *never* found a .OBJ file that I did not compile myself that would link with Turbo Pascal (unless it was expressly written to do so). Borland put such stringent requirements on linking external modules that for all intents and purposes it can't be done unless you are willing to write the code yourself. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Bob Beauchaine bobb@vice.ICO.TEK.COM C: The language that combines the power of assembly language with the flexibility of assembly language.
mwizard@jove.cs.pdx.edu (Craig R. Nelson) (04/07/91)
amead@s.psych.uiuc.edu (alan mead) writes: >seth@wet.UUCP (Seth Olitzky) writes: >>In article <2941@cod.NOSC.MIL> vtran@cod.NOSC.MIL (Viet D. Tran) writes: >>> >>>I have programs that were written in two different languages, Pascal >>>and C. Now, I am having trouble combining them together, or linking >>>... >>A lot depends on what compilers and target machine you are using. Borland >>pascal TPU are not compatible with Borland C objects. You will need to >>... >Actually, I think any .OBJ file can be linked to Turbo Pascal (probably >most other popular compilers as well). The problem is whether or not >pascal can use the code. >The answer is usually yes--Ohlsen and Stoker have a longish chapter on >linking C with Turbo Pascal in _Advanced Techniques in Turbo Pascal_ >(<- that's only an approximate title :( Mention on other thing. Lets not have everyone out there trying to write C functions a linking them into Pascal just so they can call their techincal reps and raise hell when it doesn't link or doesn't run properly. Remember to enforce Pascal calling conventions on the C code when it is being compiled. This is the primary reason that standard runtime library routines will not link in correctly. Also, lets remember to drop the damn underscore. []====================================================================[] || Craig R. Nelson | CCSofD Software Inc. || || Programmer | Beaverton, OR, 97005 || || mwizard@eecs.ee.pdx.edu | (unlisted on the net) || ||====================================================================|| || The opinions expressed here are mine. No one gave them to me. || || Since I own half of it they are also the companie's opinons. || || (but only fifty-percent of the time.) || []====================================================================[]
bb16@prism.gatech.EDU (Scott Bostater) (04/08/91)
In article <1991Apr5.211211.24087@ux1.cso.uiuc.edu> amead@s.psych.uiuc.edu (alan mead) writes: [discussion of linking .obj files with TP deleted] > Sadly, I know of no Pascal compiler that compiles to .OBJ >format; as a result, you cannot link Pascal code into other languages. Well, both Micro$oft Quick Pascal and Stoney Brook Pascal compile to OBJ files. They both claim TP compatibility too. (I have no idea how close there claims are to being true). Anyway, the bottom line is YES it can be done, and NO I wouldn't want to do it myself. -- Scott Bostater Georgia Tech Research Institute - Radar Systems Analysis "My soul finds rest in God alone; my salvation comes from Him" -Ps 62.1 uucp: ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!bb16 Internet: bb16@prism.gatech.edu
bobb@vice.ICO.TEK.COM (Bob Beauchaine) (04/10/91)
In article <25798@hydra.gatech.EDU> bb16@prism.gatech.EDU (Scott Bostater) writes: > >Well, both Micro$oft Quick Pascal and Stoney Brook Pascal compile to OBJ files. >They both claim TP compatibility too. (I have no idea how close there claims >are to being true). Anyway, the bottom line is YES it can be done, and NO I >wouldn't want to do it myself. > No, Microsoft Quick Pascal does *NOT* compile to .OBJ format (it links in memory, just like Turbo). MS Pascal *might*, I'm not sure. Microsoft Quick Pascal comes close to Turbo 5.0 compatibility, but neglected overlay support completely. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Bob Beauchaine bobb@vice.ICO.TEK.COM C: The language that combines the power of assembly language with the flexibility of assembly language.