[comp.os.msdos.programmer] TurboC++ link question...

rk29@cunixb.cc.columbia.edu (Robert Kulagowski) (12/27/90)

     Briefly, my question is this:
       In Programmer's Journal Magazine there's been a series of articles
for upping graphics function speeds by writing them in assembler.  I've
tried to link them in, but have had _no_ luck at all. The linker is giving me
an "unknown symbol" error in the modules which reference the assembler
routines. Now, I've already used MASM to compile the assembler source into
.OBJ; in the Project menu I have the 3 source files which make up the program.
Two are C, one is the .OBJ file. Can someone give me a walkthrough of getting
the linker in the IDE to include the .OBJ file? Needless to say, the manuals
weren't very helpful...

a563@mindlink.UUCP (Dave Kirsch) (01/02/91)

> wallis@labc.enet.dec.com writes:
> 
> Msg-ID: <18616@shlump.nac.dec.com>
> Posted: 2 Jan 91 15:34:05 GMT
> 
> Org.  : Digital Equipment Corporation
> Person: Barry L. Wallis
> 
> 
> In article <1990Dec26.205710.24627@cunixf.cc.columbia.edu>,
> rk29@cunixb.cc.columbia.edu (Robert  Kulagowski) writes...
> >
> >     Briefly, my question is this:
> >       In Programmer's Journal Magazine there's been a series of articles
> >for upping graphics function speeds by writing them in assembler. I've
> >tried to link them in, but have had _no_ luck at all. The linker is giving
> me
> >an "unknown symbol" error in the modules which reference the assembler
> >routines. Now, I've already used MASM to compile the assembler source into
> >..OBJ; in the Project menu I have the 3 source files which make up the
> program.
> >Two are C, one is the .OBJ file. Can someone give me a walkthrough of
> getting
> >the linker in the IDE to include the .OBJ file? Needless to say, the manuals
> >weren't very helpful...
> 
> If you are using Turbo C++ (as opposed to Turbo C) you should define the
> prototype for the assembler routines as extern "C". For example:
> 
> extern "C" void line(int, int);
> 
> I don't have my manuals with me, but, I'm fairly sure of the above syntax.

You must have been a Fortran programmer, as that is the syntax you gave, which
is incorrect.  The syntax should be:

extern cdecl void line(int, int);

Also, cdecl declared functions will have a leading underscore (_) placed on
them.  What that means is when you link, it will be looking for "_line", not
just "line".  You have to declare the assembler function as "_line proc" not
"line proc".  Unless you are using the simple segment directives with the C
model option (i.e. "model large, c").

--
--
/// Dave 'Zoid' Kirsch UUCP: {uunet,ubc-cs}!van-bc!rsoft!mindlink!a563
Voice: (604) 585-8844        a563@mindlink.UUCP
                             Zoid@cc.sfu.ca
                       Vancouver, British Columbia
"In-no-sense?  Nonsense!" - The Art Of Noise.

wallis@labc.enet.dec.com (Barry L. Wallis) (01/02/91)

In article <1990Dec26.205710.24627@cunixf.cc.columbia.edu>, rk29@cunixb.cc.columbia.edu (Robert  Kulagowski) writes...
> 
>     Briefly, my question is this:
>       In Programmer's Journal Magazine there's been a series of articles
>for upping graphics function speeds by writing them in assembler.  I've
>tried to link them in, but have had _no_ luck at all. The linker is giving me
>an "unknown symbol" error in the modules which reference the assembler
>routines. Now, I've already used MASM to compile the assembler source into
>..OBJ; in the Project menu I have the 3 source files which make up the program.
>Two are C, one is the .OBJ file. Can someone give me a walkthrough of getting
>the linker in the IDE to include the .OBJ file? Needless to say, the manuals
>weren't very helpful...

If you are using Turbo C++ (as opposed to Turbo C) you should define the
prototype for the assembler routines as extern "C". For example: 

extern "C" void line(int, int);

I don't have my manuals with me, but, I'm fairly sure of the above syntax.

---
Barry L. Wallis			USENET: wallis@labc.dec.com
Database Consultant		Prodigy (don't laugh): DNMX41A
U.S. DECtp Resource Center	DECUServe: EISNER::WALLIS (not on the net yet)
Los Angeles, CA			"No one voted for me, I represent myself"
---

sverrehu@ifi.uio.no (Sverre H Huseby) (01/03/91)

> 
>      Briefly, my question is this:
>        In Programmer's Journal Magazine there's been a series of articles
> for upping graphics function speeds by writing them in assembler.  I've
> tried to link them in, but have had _no_ luck at all. The linker is giving me
> an "unknown symbol" error in the modules which reference the assembler
> routines. Now, I've already used MASM to compile the assembler source into
> .OBJ; in the Project menu I have the 3 source files which make up the program.
> Two are C, one is the .OBJ file. Can someone give me a walkthrough of getting
> the linker in the IDE to include the .OBJ file? Needless to say, the manuals
> weren't very helpful...

Make sure the files are assembled with case-sensitive symbols.
With TASM this is done with the /ml -switch. I'm not sure how
it is done with MASM.



Sverre.

----------------------------------------
Sverre H. Huseby   (sverrehu@ifi.uio.no)
Student   -   University of Oslo, Norway

anto@vaxb.acs.unt.edu (01/04/91)

In article <4296@mindlink.UUCP>, a563@mindlink.UUCP (Dave Kirsch) writes:
>> wallis@labc.enet.dec.com writes:
>>
>> If you are using Turbo C++ (as opposed to Turbo C) you should define the
>> prototype for the assembler routines as extern "C". For example:
>> 
>> extern "C" void line(int, int);
>> 
>> I don't have my manuals with me, but, I'm fairly sure of the above syntax.
> 
> You must have been a Fortran programmer, as that is the syntax you gave, which
> is incorrect.  The syntax should be:
> 
> extern cdecl void line(int, int);
> 

The first one is correct. It's a C++ syntax, _NOT_ C. Actually it's either:

extern "C" void line (int, int);

.. or

extern "C" { void line (int, int); }

You can use the latter if you want to put more than 1 function prototype
between the braces (if you have more than 1 C function you want to use in a C++
program).

Anto.