I have include the math.h in my c file, however it keeps prompts undefined reference to trunc
and undefined reference to ceil
. And I didn't even use trunc in my file. Could anyone tell what was the problem?
Asked
Active
Viewed 8,945 times
2

Blake
- 7,367
- 19
- 54
- 80
-
6Possibly you're using gcc and have forgotten to link to libm.a by adding `-lm` to your command line? Its hard to say when you don't include any code or a note of your build command. – simonc Nov 17 '13 at 23:16
-
Are you getting complaints from the compiler or the linker? It looks to me like the compiler, though other folks here have answered how to make the linker link with the math library (`-lm`). What compiler are you using? – kmort Nov 18 '13 at 02:46
2 Answers
1
It seems that you will need the info about how C source code are compiled and linked together. The link contains some basic info: Compile & Link
You use -I option of gcc to specify where to find headers, and -l option to link standard libraries