-lm lib was indicated at the start of the project.
Im using the math.h include also.
So why do I keep getting it when using sqrt?
Kdevelop btw.
Printable View
-lm lib was indicated at the start of the project.
Im using the math.h include also.
So why do I keep getting it when using sqrt?
Kdevelop btw.
Your problem is right there.
No, there. That's it.
Quzah.
Im sorry?
It may well be how you specified -lm. I don't use kdevelop so I can't say.
When linking on UNIX, if a code module A depends on code module B, then module B must be listed after module A on the link line.
This is wrong:
This is right:Code:gcc -lm -o myprogram myprogram.c
Code:gcc -o myprogram myprogram.c -lm
Oh, I was just using my psychic powers to spot the issue. I assumed you'd use yours to see where I found the problem. Or you could search the forums and see what everyone else did. Or you could just compile it via command line:
gcc -o foo foo.c -lm
Quzah.
If a bit of thinking would solve it I would not browse the web trying to get an answer and ultimatly posting.
Im quite new to this and so I asked, thanks for the replies though, I can understand that every other thread is made by someone with a bit more knowledge so you're used to that :P
While I can't presume to speak for quzah, I'm assuming he was just referring to your original post when you said:
That jumped out at me right away before even reading the replies. So it almost seemed like you answered your own question right there. But I can certainly understand the whole deal... hey we've all been there.Quote:
-lm lib was indicated at the start of the project
Has nobody mentioned circular references yet? I haven't had to deal with those since my days on the DEC Alpha... either my code has gotten better or the linker has gotten smarter.
Yes, I've had problems with circular references before. Usually it means that two libraries which are separate are actually just two parts of a single library and should be merged. But in some cases the code is broken into libraries only for reasons of convenience. In either case the circular references are painful, but can always be resolved by:
Where A and B are mutually dependent libraries.Code:-lA -lB -lA