07-21-2014 01:17 AM
I'm getting "undefined reference to 'sqrtf'" errors from the linker. This is a standard C99 library function with declaration in math.h. I've tried adding "-std=c99" arguments to the gcc compile and link settings. Do I need to add the standard C libraries to the project?
What else could be the problem?
07-21-2014 01:47 AM
Can you post your c code that you would want to compile?
I see that this is already defined in math.h
extern float sqrtf _PARAMS((float));
Also please confirm which version of SDK you are using.
07-21-2014 10:46 PM
I'm using v2014.2. The problem with posting the code is that I'm porting quite a large project with many source files.
Trying to produce some minimal code that shows the problem. In the process so far I have found a couple of symptoms.
1. I get the same linker error when I change the function call to sqrt(), which is a C90 function.
2. I don't get the error if I remove it from the the file it is in, but call sqrtf() from main.c, the file that has main() in it.
3. Even with identical #include's I get the error for calls in 1 file, but not main.c.
4. It doesn't seem to be a name mangling problem, because I still get the error if I add the prototype "float sqrtf(float);" just before the function that calls it and gives the linker error.
5. The error is still there if I add libm.a to the project.
Still wracking my brain.
07-22-2014 12:01 AM
07-22-2014 01:14 AM
OK I've managed to produce a minimal setup that gives me the error.
SDK created the hardware from the attached .hdf file. I created a brand new baremetal hello_world application project, allowing SDK to create a new BSP. I added "#include <math.h>" and a function that calls sqrt() to hello_world.c (to get the attached hello_world.c). Saved hello_world.s and ....boom.... I got the "undefined refernce" linker error.
The fact that I'm the only person having this problem suggests I must be doing something blindingly obviously wrong, I have a corrupted installation, or there's some incompatibility between v2014.2 and WinXP.
12-06-2014 10:26 PM
Try this, I got it from a Zedboard/Vivado workshop tutorial I have been using:
Right-click on the “Your Project” project in the Project Explorer, and choose “C/C++ Build Settings”.
Choose the “ARM gcc linker Libraries” section.
Click the “Add...” button in the “Libraries” pane at the top. (The button is the one with the green “+” sign on the document icon)
Type “m” in the entry field and then click “OK”.
Click “OK” to return to the main SDK window.