Hi, I am quite new to Fastrack and Open At. I am trying to use the function sqrt but the system doesn’t recognize that despite putting in #include <math.h>.
Hope to get some advice from the experts.
Thanks!
What do you mean by that?
What messages, exactly, do you get?
Copy and paste the full message text - do not attempt to manually re-type it.
Hi, awneil,
Thank you for your help.
Below is the exact message:
c:\OpenAT\IDE\MINGW\3.8.0.1\bin\make.exe: *** [make_single_bin] Error 1
/cygdrive/d/Projects/Test_TT/gcc/out/queryapp.c:278: undefined reference to `sqrt’
Done.
I have added #include “math.h” to queryapp.c but it doesn’t work.
I am trying to use the C function, sqrt.
Maybe you should add the math library to the application using -lm in the linker options
That looks like a Compiler error - is it
That should fix a Linker error - but not a Compiler error …
Have you confirmed that math.h actually exists on your system?
Are your include paths correctly configured?
On my system, there’s a lot of #if tests in math.h - are you sure that you have everything configured correctly?
Do other maths functions work?
Have you tried a search for “sqrt” on the forum…
Normaly errors like undefined reference to `sqrt’ are linker errors because the compiler has no informations about unresolved references. If the compiler cannot find a function it shows warnings like implicit declaraton of function ‘sqrt’.
True; but then Linker messages usually refer to the Linker input files (ie, object files) - not to .c source files…
Agreed.
It does seem a little confusing…
Yes, you are right — it is a little bit confusing.
Meanwhile I made a short test (replacing a wm_strlen() by wm_strlenx()). The compiler shows
and the file gcc_OpenAT_Test_err_lnk.txt contain the lines
I assume the linker is able to read the debug informations in the object file to refer to the correct line in the source which will be very helpful for programmers …
Please ignore the paths in the output of the compiler and the linker, I use an own tool-chain instead of the original OpenAT tool chain but the messages are similar.
That’s good - I’ve never really understood why a Linker shouldn’t be able to do that…