'undefined reference' link errors while building from source

Asked by scarpaz on 2013-11-30

Hi,
i'm building libecbufr from sources on ubuntu 13.10 for an x86_64 target.
I'm getting these link errors while linking the examples:

/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `nan'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `logf'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `__fpclassify'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `powf'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `__fpclassifyf'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `rint'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `nanf'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `log'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `pow'
/home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `round'
collect2: error: ld returned 1 exit status

after the last build command was:

/bin/bash ../libtool --tag=CC --mode=link gcc -I/home/xxx/libecbufr/API/Headers -I/home/xxx/libecbufr/API/Sources -std=gnu99 -D_REENTRANT -fPIC -g -L/home/xxx/libecbufr/API/Sources -o bufr_merge bufr_merge.o -L../API/Sources -L/usr/lib/libecbufr0 -lecbufr -lm
libtool: link: gcc -I/home/xxx/libecbufr/API/Headers -I/home/xxx/libecbufr/API/Sources -std=gnu99 -D_REENTRANT -fPIC -g -o .libs/bufr_merge bufr_merge.o -L/home/xxx/libecbufr/API/Sources -L/usr/lib/libecbufr0 /home/xxx/libecbufr/API/Sources/.libs/libecbufr.so -lm -Wl,-rpath -Wl,/home/xxx/lib/libecbufr0.8.5

Most undefined symbols seem to be from the math library, which seems pretty weird.

Question information

Language:
English Edit question
Status:
Solved
For:
libECBUFR Edit question
Assignee:
No assignee Edit question
Solved by:
scarpaz
Solved:
2014-01-08
Last query:
2014-01-08
Last reply:
2014-01-08

This question was reopened

scarpaz (scarpaz) said : #1

P.S.: I solved the issue by adding "LIBS=-lm" to my ./configure line, but I still think that this workaround should not be needed.

Thanks.

Agreed. The issue is noted, thanks for reporting.

Yves

cpb (chris-beauregard) said : #3

What makes it particularly odd is that "-lm" is already in the libtool link line.

Did you "sh reconf" before running ./configure? If not, my guess would be an incompatibility between the stock configure and 13.10. I build on a whole variety of Debian and Ubuntu versions (x32 and x64) without issue and always start with a reconf.

scarpaz (scarpaz) said : #4

Yes, I did run "sh reconf" before "./configure ...".
It does not seem to make a difference.
Is it relevant that I am building with "--enable-static --disable-shared"?

Thanks

For what it's worth, I ran a test on my own machine and compiled libecbufr and utilities successfully after the following command: "./configure --enable-static --disable-shared". At a workshop I gave in November, I've witnessed a number of compiles on my own machine and others, under debian, ubuntu, redhat, fedora and sabayon (a gentoo derivative). In that recent sample, and in the more distant past, I have seen occasional issues, usually with dependencies, but not the behaviour you describe. When I have access to a Ubuntu 13.10 machine, I might try again.

scarpaz (scarpaz) said : #6

Thank you for your prompt response.
Thanks to the workaround I'm not stuck, but if you need more details about my case feel free to ask.
I can send you the intermediate build outputs.
Happy new 2014.

Thanks

cpb (chris-beauregard) said : #7

> Is it relevant that I am building with "--enable-static --disable-shared"?

Yes, it's very relevant, because the error messages:

> /home/scarpaz/gaiag/gaiagsdk_2013_11_30/external/libecbufr/libecbufr/API/Sources/.libs/libecbufr.so: undefined reference to `*'

suggest that it's trying to link against a shared library (.so vs .a). I've never tried building it as a static library, but it looks like you may need to adjust the CFLAGS settings in configure.in to make it work.