UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor jg-b
Visitor
247 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 ericv
Scholar
189 Views
Registered: ‎04-13-2015

Re: Undefined reference to pow despite linking to libm

Jump to solution

@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.

6 Replies
Moderator
Moderator
226 Views
Registered: ‎09-12-2007

Re: Undefined reference to pow despite linking to libm

Jump to solution
0 Kudos
Visitor jg-b
Visitor
215 Views
Registered: ‎09-14-2017

Re: Undefined reference to pow despite linking to libm

Jump to solution

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
Moderator
Moderator
207 Views
Registered: ‎09-12-2007

Re: Undefined reference to pow despite linking to libm

Jump to solution

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
Visitor jg-b
Visitor
201 Views
Registered: ‎09-14-2017

Re: Undefined reference to pow despite linking to libm

Jump to solution

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 ericv
Scholar
190 Views
Registered: ‎04-13-2015

Re: Undefined reference to pow despite linking to libm

Jump to solution

@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.

Visitor jg-b
Visitor
180 Views
Registered: ‎09-14-2017

Re: Undefined reference to pow despite linking to libm

Jump to solution

That indeed did the trick.

Thank you.

0 Kudos