[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

lib/libgsl.so: undefined reference to `cblas_ztrsv' (on Ubuntus)

Hi Everyone,

Though it is actually not a Debian specific question (since on pure
Debian builts/links fine), I hope to find help and wisdom here.  

We (neurodebian) have a package for AFNI which we have been cooking for a
while... with a recent change to force -Wl,--no-undefined I got into a weird
linking issue which happens only on Ubuntu boxes (11.10 and up) while building
fine on Debian.  In the gcc call where linking '-lgsl -lgslcblas' fails
for no obvious for me reason -- order of libraries inclusion is fine, symbols
are there (even found/reported by ld) but still then reported not found. What
could be the reason?

The only obvious difference from Debian builds is addition of
-Wl,-Bsymbolic-functions for linking calls but even if I remove it for this
specific call -- nothing changes (although may be it is an effect of gsl being
built with it?)

See below what I am talking about and please find complete logs at

so here it is -- gslcblas has the definitions, I do have -lgsl
-lgslcblas, according to strace gslcblas is read at least -- but references are
still undefined:

~/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu/avovk# nm -D /usr/lib/libgslcblas.so | grep cblas_dgemv  000000000000ea00 T cblas_dgemv

~/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu/avovk# gcc  --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wformat-security -g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-unused  -fopenmp -DUSE_OMP  -Wl,-z,now -Wl,-z,relro -Wl,--no-undefined
CMakeFiles/3dkmeans.dir/3dkmeans.c.o CMakeFiles/3dkmeans.dir/cluster_floatNOMASK.c.o CMakeFiles/3dkmeans.dir/thd_segtools_fNM.c.o  -o 3dkmeans
../libmri.so ../libmrix.so ../coxplot/libcoxplot.so libsegtools.so -lSM -lICE -lX11 -lXext -lXm -lXmHTML ../libmri.so -lvolpack -lnetcdf -lXt -lf2c
-lgiftiio -lnifticdf -lniftiio -lz -lnifticdf -lniftiio -lz -lgsl  -lgslcblas -lm
fni-0.20130830~dfsg.1/build-x86_64-linux-gnu/avovk:" -DNDEBUG
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so: undefined reference to `cblas_ztrsv'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so: undefined reference to `cblas_scasum'

and here you can see that ld finds the definition but then reports that it is
undefined in libgsl.so (which is factually true but I thought it would use the
one from libgslcblas by then).

~/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu/avovk# /usr/bin/ld --verbose -t -y cblas_ztrsv --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o 3dkmeans /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. -z now -z relro --no-undefined CMakeFiles/3dkmeans.dir/3dkmeans.c.o CMakeFiles/3dkmeans.dir/cluster_floatNOMASK.c.o CMakeFiles/3dkmeans.dir/thd_segtools_fNM.c.o ../libmri.so ../libmrix.so ../coxplot/libcoxplot.so libsegtools.so -lSM -lICE -lX11 -lXext -lXm -lXmHTML ../libmri.so -lvolpack -lnetcdf -lXt -lf2c -lgiftiio -lnifticdf -lniftiio -lz -lnifticdf -lniftiio -lz -lgsl -lgslcblas -lm -rpath /tmp/buildd/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu:/tmp/buildd/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu/coxplot:/tmp/buildd/afni-0.20130830~dfsg.1/build-x86_64-linux-gnu/avovk:  -lgomp -lgcc --as-needed -lgcc_s  -lpthread -lc -lgcc  -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o 2>&1  | grep -e 'gsl' -e 'cblas_ztrsv' | head -20
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so succeeded
-lgsl (/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so)
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so: reference to cblas_ztrsv
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgslcblas.so succeeded
-lgslcblas (/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgslcblas.so)
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgslcblas.so: definition of cblas_ztrsv
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so: undefined reference to `cblas_ztrsv'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libgsl.so: undefined reference to `cblas_scasum'

probably needless to say that adding -lcblas works around this issue.

Thanks in advance for the hints!
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Senior Research Associate,     Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        

Reply to: