#Floating all at C
5 messages in this thread
Hello out there, I`m new to this compuserve thing, so if I make a few
errors I trust you`ll forgive me. I`m trying to learn C programming
on an Amiga 4000/30 using SAS C Version 6, so far so good, until I
hit the subject of Floating point numbers, the book I`m learning from
says to use Float when declareing variables and use %f in printf and
scanf's When I try to compile the Linker comes up with an error and
says the prop math library has not been included, the program when
run says that an undefined stub routine has been called, I`m afraid
this is double dutch to me can anybody advise? I`ve tried a few
librarys at random with no luck. HELP!! thanx Paul Tyler…
I work with Manx myself, but I might be able to guide you a little.
When I want to use floating point routines in my code (which is
almost never), I have to link using both m.lib and c.lib . Whereas,
I only use c.lib if I'm not doing floating point.
So, my link command would look like this:
ln sqrroot.o -lm -lc
and the -lm *has* to come before the -lc.
Mike McCormick
Paul,
It depends on how you are compiling. If you have written a makefile
then you need to add the appropriate compiler flag to include one of
the math libraries. From the nature of the question though, I'll bet
that you are either pressing F4 within the editor or double clicking
on the build icon to compile your program. In this case, simply
double click the SCoptions icon, click on the Code Options button and
then click on the button that says NoMath until it gives you the
appropriate math library (probably Math=Standard). Save the
configuration and recompile. If you use floating point math most of
the time you may want to save your configuration as the default so
that any new projects will already have that library set for linking.
Paul, The same thing happens often to me, especially when it has been some time
I programmed. Please check the following ( this is what goes wrong with me) In
your SOURCE file, is there a line like this: #include math.h
It may be very stupid, but if you omit this one, your program will compile
beautifull, but when you link, you get a message from the linker like:
'Undefined Symbols _CXD55, first referenced in …. when you then just press
<ENTER>, the linker goes on without any complaints and produces a nice program.
But when you run it, you get an error message like you described. Greetings
from The Netherlands, Rob Zijlstra
I'm not too familiar with C fin the Amiga computer, but I will tried to help.
In MSDOS, you must include #include <math.h>, do you have this line in your
source code?