libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
544 stars 305 forks source link

Latest libplist does not link properly #157

Closed pekn closed 4 years ago

pekn commented 4 years ago

Latest libplist does not link properly

The following error occurs:

../src/.libs/libplist.so: undefined reference to `fmin'

(Tested with Ubuntu 18.04)

Should libplist link against libm as well?

nikias commented 4 years ago

Hi. It builds fine on x86_64, but it looks like there's a CPU instruction that handles it. Can you change fmin in the code to __builtin_fmin and see if that will make it work without libm?

nikias commented 4 years ago

Also according to this: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html GCC should automatically handle fmin and some others as builtin functions... so hmm...

pekn commented 4 years ago

I changed to __builtin_fmin and still gives same error.

zinglax commented 4 years ago

Out in left field here with this stuff but is fmin part of the math.h? if so this says to link the math library by adding the -lm flags when compiling with gcc

grubec commented 4 years ago

I can confirm the error message on Ubuntu 18.04 on a x64 as well as arm architecture (raspian buster).adding -lm to the compiler flags doesn't help.

nikias commented 4 years ago

@grubec it's in plist.c not in plist.h @zinglax @pekn I just pushed commit ce1092a5fc83e1b5590128b5f642200c382451a6 which should add -lm to the linker flags if required. Let me know if this works.

grubec commented 4 years ago

@nikias Thank you very much! ... just figured out my mistake as well ;)

grubec commented 4 years ago

tried it, but is still gives me a: CC plistutil.o CCLD plistutil ../src/.libs/libplist.so: undefined reference to `fmin' collect2: error: ld returned 1 exit status Makefile:418: recipe for target 'plistutil' failed make[2]: *** [plistutil] Error 1

same as if I add -lm manually :(

nikias commented 4 years ago

Yes... I just started an old ubuntu 12.04 VM and it shows me the same. Working on it.

nikias commented 4 years ago

Can you try with commit https://github.com/libimobiledevice/libplist/commit/a2d66545d1303dd2cb5e0d56761aaf8a96bbc282 ? Make sure to also do make clean and run autogen.sh again.

grubec commented 4 years ago

Yes, that did the trick. Thanks @nikias

nikias commented 4 years ago

It also works on my ubuntu 18.04 x86_64 but my compiler just replaces it with a floating point CPU instruction 🤷‍♂️ With the check I added it will add -lm if required. Anyway, @pekn it should also work for you now. Feel free to re-open if the problem persists.