ewing@se-sd.NCR.COM (David Ewing) (02/21/90)
I get an "undefined symbol" message at link time when I compile
and link the following test program on Lattice C 5.04 --
#include <stdio.h>
main()
{
float fl = 1.0;
printf("%f\n", fl);
}
I simply compiled it and linked it by typing "lc -L dummy" (
the program was dummy.c).
The problem is definetly with the %f format, it works fine if the
float is replaced by an int and %d is used.
I am an experienced C programmer but completely new to programming
on the Amiga. I suspect that the linker is not pulling in some
floating point library.
Please email any help to ewing@se-sd.sandiego.ncr.com. My apologies
if this is completely bone-headed or has been discussed ad infinitum
(I couldn't find any reference in my perusal of newuser).
Dave Ewing
ewing@se-sd.sandiego.ncr.com
mitchell@cbmvax.commodore.com (Fred Mitchell - Product Assurance) (02/22/90)
In article <2427@se-sd.NCR.COM> ewing@se-sd.SanDiego.NCR.COM (David Ewing) writes: > >I get an "undefined symbol" message at link time when I compile >and link the following test program on Lattice C 5.04 -- > >#include <stdio.h> > >main() >{ > float fl = 1.0; > printf("%f\n", fl); >} > >I simply compiled it and linked it by typing "lc -L dummy" ( >the program was dummy.c). > You have to specify a floating-point library when using floating-point. One option: lc -Lm dummy Will work. See your Lattice manual for a complete discussion. >Dave Ewing >ewing@se-sd.sandiego.ncr.com -Mitchell mitchell@cbmvax.UUCP
markv@kuhub.cc.ukans.edu (02/22/90)
> I get an "undefined symbol" message at link time when I compile > and link the following test program on Lattice C 5.04 -- > > #include <stdio.h> > > main() > { > float fl = 1.0; > printf("%f\n", fl); > } > > I simply compiled it and linked it by typing "lc -L dummy" ( > the program was dummy.c). Yes, you need to say "lc -Lm dummy". The m tells lc to tell BLink to use the lcm.lib (default math library). You can tell lc "-LXXX" where XXX is the name of any link library (minus the lc). So to use the FFP library instead (lcmffp) as an example say "lc -Lmffp dummy". By the way, the Lattice 5.04 libraries have some bugs in their handling of the %f stuff, (CodeProbe does too). These are fixed with the 5.04a pathes which are available on BIX or the Lattice BBS. > The problem is definetly with the %f format, it works fine if the > float is replaced by an int and %d is used. Yes, printf() does a function call to convert the %f, and that function is in the math libraries. > I am an experienced C programmer but completely new to programming > on the Amiga. I suspect that the linker is not pulling in some > floating point library. The Blink (or lc driving Blink) never automatically pulls in the math libraries, even if you give a floating point option to the compiler phase on the lc command line. > Please email any help to ewing@se-sd.sandiego.ncr.com. My apologies > if this is completely bone-headed or has been discussed ad infinitum > (I couldn't find any reference in my perusal of newuser). The documentation is fairly fuzzy on the details of which .lib or .o file is needed and does what, etc. > Dave Ewing > ewing@se-sd.sandiego.ncr.com -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: markgood \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: mark@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
walker@sas.UUCP (Doug Walker) (02/25/90)
In article <2427@se-sd.NCR.COM> ewing@se-sd.SanDiego.NCR.COM (David Ewing) writes: > >I get an "undefined symbol" message at link time when I compile >and link the following test program on Lattice C 5.04 -- I replied to this once and made a typo, so please ignore my other response if I didn't manage to cancel it. Use LC -Lm. If you use floating point, you have to link in the FP libraries. ***** =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)471-6436 = *|. o.| || | o |// Got mole problems? Call Avogadro: 602-1023! ====== usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker