cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jg-b
Visitor
Visitor
2,804 Views
Registered: ‎09-14-2017

Undefined reference to pow despite linking to libm

Jump to solution

Hello,

I am experiencing some strange behaviour in Xilinx SDK 2018.2 with a Standalone OS project for A53.

I get "undefined reference to pow" and "undefined reference to log" errors despite including math.h and linking to libm as well. Weird thing is, that references to sqrt and powf do work.

Any ideas?

Thanks,

Jürgen

0 Kudos
1 Solution

Accepted Solutions
ericv
Scholar
Scholar
2,746 Views
Registered: ‎04-13-2015

@jg-b 

Looks like you have to move -lm after --start-group - likely one of the lib refers to pow() & log() and, libm not located between --start-group / --end-group, the linker doesn't re-scan libm.

View solution in original post

7 Replies
stephenm
Xilinx Employee
Xilinx Employee
2,783 Views
Registered: ‎09-12-2007
0 Kudos
jg-b
Visitor
Visitor
2,772 Views
Registered: ‎09-14-2017

Thank you for the hint.

Alas the AR you are referring to suggests linking to libm.

As I already mentioned, that I did in the first place.

0 Kudos
stephenm
Xilinx Employee
Xilinx Employee
2,764 Views
Registered: ‎09-12-2007

You have the math library linked, but not added (this is what the AR is trying to convey)

I took a simple example (as shown below), this failed if the math library wasnt added:

pow_error.PNG

To fix this, I right clicked on the app, and choose C/C++ Build Settings, and added the math library as shown:

math.PNG

This built successfully:

command.PNG

0 Kudos
jg-b
Visitor
Visitor
2,758 Views
Registered: ‎09-14-2017

OK, sorry for the misunderstanding, added vs. linked, and thank you for clarifying.

Actually the settings in my project look just the same as yours, though, so libm is actually added, together with a custom library.

0 Kudos
ericv
Scholar
Scholar
2,747 Views
Registered: ‎04-13-2015

@jg-b 

Looks like you have to move -lm after --start-group - likely one of the lib refers to pow() & log() and, libm not located between --start-group / --end-group, the linker doesn't re-scan libm.

View solution in original post

jg-b
Visitor
Visitor
2,737 Views
Registered: ‎09-14-2017

That indeed did the trick.

Thank you.

0 Kudos
pedro_uno
Advisor
Advisor
1,570 Views
Registered: ‎02-12-2013
I have the same exact problem in Vitis but cannot find the entry to add libm to the link list.
How is this done in Vitis?
----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos