rlcarr@athena.mit.edu (Rich Carreiro) (11/22/89)
I have updated to Lattice 5.04 and am having problems with using registerized parameters. My compile line is: lc -v -rr -Lcdv detab.c (yes, from good old K+R) There is an added #include <stdlib.h> along with the #include <stdio.h> that is part of the program. OK, it compiles fine, but when it begins to link I get: Undefined Symbol First Referenced ---------------- ---------------- @main LIB:lcr.lib Note that I DO NOT have a prototype for main(). According to the lattice manual, not having a function prototype this means that the compiler will default to passing args on the stack for that function. If I have mixed standard args and registerized args, do I have to link against BOTH lc.lib and lcs.lib, or is that unnessesary? Or is this a bug and the compiler is generating an incorrect symbol or an error in the symbol name within the library. I get the same error when I use the -w option to lc (16 bit ints) except that the first referenced is LIB:lcsr.lib. Thank you for any help. -- Rich Carreiro - Most Biased Boston Celtics Fan! Get well soon, Johnny Most! ARPA: rlcarr@space.mit.edu Welcome back, Larry! UUCP: ...!mit-eddie!space.mit.edu!rlcarr McHale, 6th man supreme! BITNET: rlcarr@space.mit.edu "Follow through!"
cmcmanis%pepper@Sun.COM (Chuck McManis) (11/22/89)
In article <1989Nov22.022406.9843@athena.mit.edu> (Rich Carreiro) writes: >OK, it compiles fine, but when it begins to link I get: >Undefined Symbol First Referenced >@main LIB:lcr.lib There is a prototype for main() in the stdlib.h file. Delete it and all will work as expected. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@Eng.Sun.COM These opinions are my own and no one elses, but you knew that didn't you. "If it didn't have bones in it, it wouldn't be crunchy now would it?!"
mwm@eris.berkeley.edu (Mike (With friends like these, who needs hallucinations) Meyer) (11/23/89)
In article <128264@sun.Eng.Sun.COM> cmcmanis@sun.UUCP (Chuck McManis) writes: <In article <1989Nov22.022406.9843@athena.mit.edu> (Rich Carreiro) writes: <>OK, it compiles fine, but when it begins to link I get: <>Undefined Symbol First Referenced <>@main LIB:lcr.lib < <There is a prototype for main() in the stdlib.h file. Delete it and all <will work as expected. Lattice deleted that for you in 5.04 (ths problem is tagged as being 5.04). Besides which, the problem is that the prototyped main (@main) is missing, not that the unprototyped main (_main) is missing. You can link with both libraries, and that may fix it. Try them in both orders, though. Dropping the -rr compiler flag should also fix the problem. The best solution is to not mix the two forms in the same program. <mike
walker@sas.UUCP (Doug Walker) (11/27/89)
In article <1989Nov23.032623.13429@agate.berkeley.edu> mwm@eris.berkeley.edu (Mike (With friends like these, who needs hallucinations) Meyer) writes: >In article <128264@sun.Eng.Sun.COM> cmcmanis@sun.UUCP (Chuck McManis) writes: ><In article <1989Nov22.022406.9843@athena.mit.edu> (Rich Carreiro) writes: ><>OK, it compiles fine, but when it begins to link I get: ><>Undefined Symbol First Referenced ><>@main LIB:lcr.lib The problem here is that the startup code (c.o or whatever) refers to the routine __main in the libraries, which in turn refers to your main routine. Since you are linking with the registerized library, it calls main as a The at sign before the name indicates the routine is being called registerized; the underbar indicates it is being called stack-based. This prevents a possibly catastrophic mix of registerized and stack-based calls, and instead results in a link error (like this one). The fix is one of two things: 1. BEST - stick in a prototype for main. This will cause __main to call it registerized and everything will work fine. 2. NOT SO GOOD - link with lc.lib BEFORE lcr.lib. This will resolve the symbol __main to the NON-registerized version. It will also resolve any other library routines that you didn't include the prototype for, which hopefully is none of them. This method has the disadvantage of hiding non-registerized calls that you may not have intended to be non-registerized. ***** *|_o_o|\\ Doug Walker, Software Distiller *|. o.| || | o |// "It is well to remember that evil is a pretty bad thing." ====== usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker