cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
1,350 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
Highlighted
Scholar
Scholar
1,292 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
Highlighted
Moderator
Moderator
1,329 Views
Registered: ‎09-12-2007
0 Kudos
Highlighted
Visitor
Visitor
1,318 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
Highlighted
Moderator
Moderator
1,310 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
Highlighted
Visitor
Visitor
1,304 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
Highlighted
Scholar
Scholar
1,293 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

Highlighted
Visitor
Visitor
1,283 Views
Registered: ‎09-14-2017

That indeed did the trick.

Thank you.

0 Kudos
Highlighted
Advisor
Advisor
116 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