On Thu, 30 May 2002 16:52:56 BST, =?iso-8859-1?B?TeFpcnTtbiBPIFN1bGxpdmFu?= said:
>This is probably very simple but I've just started to learn to program C on
>an old Linux box (distribution is SuSE from about four years ago). Problem
>is gcc (which I'm assuming is the right compiler) doesn't seem to be
>recognising any of the .h files. I've included them in the code correctly
>but any functions relating to them are going unrecognised by the compiler
>and it spits out an error.
>The problem in question is math.h and the fmod function.
>>Is there a path which must be set for gcc?
>>I'm guessing this is incredibly simple but it's been a long time since I've
>been using linux so hopefully you lot should be able to sort is out.
If the error you're getting looks something like
/tmp/ccgP0Yjc.o: In function `main':
/tmp/ccgP0Yjc.o(.text+0x1c): undefined reference to `cos'
it may just be that you need to link off the maths libraries... try
doing this for your compile instead...
gcc -o test test.c -lm
That bit is what tells the compiler what libraries it needs to look
for... libm is the maths library.
[If you do (for example)
you'll see a section up the top which says LIBRARY. That has the
line down the end (-lm) which you'll need to give to the compiler.
Same counts for other stuff...]
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!