Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make misc/test_blas failed in ubuntu14.04 #487

Closed
1 task done
shutcode opened this issue Jun 12, 2018 · 3 comments
Closed
1 task done

make misc/test_blas failed in ubuntu14.04 #487

shutcode opened this issue Jun 12, 2018 · 3 comments
Labels

Comments

@shutcode
Copy link

shutcode commented Jun 12, 2018

Summary

after running configure, failed to make misc/test_blas
I'm sure openblas is installed(apt-get and install from source),and the link flags are correctly set. error info as follows

test_blas.cpp:(.text+0x187):undefined reference to `sgemm_'
test_blas.cpp:(.text+0x346):undefined reference to `sgeqrf_'
collect2: error: ld returned 1 exit status

I have tried solutions from #15 and #131

Platform

OS: ubuntu 14.04
Faiss version: 1fe2872

Faiss compilation options:

g++ -std=c++11  -fopenmp  -lopenblas -llapack  -o misc/test_blas misc/test_blas.cpp
#or 
g++ -std=c++11  -fopenmp  -lopenblas -llapack -L/opt/OpenBLAS/lib -I/opt/OpenBLAS/include -o misc/test_blas misc/test_blas.cpp

Running on :

  • CPU

Reproduction instructions

./configure
make misc/test_blas.cpp
test_blas.cpp:(.text+0x187):undefined reference to `sgemm_'
test_blas.cpp:(.text+0x346):undefined reference to `sgeqrf_'
collect2: error: ld returned 1 exit status
ldconfig -p |grep openblas
	libopenblas.so.0 (libc6,x86-64) => /usr/local/lib/libopenblas.so.0
	libopenblas.so.0 (libc6,x86-64) => /usr/lib/libopenblas.so.0
	libopenblas.so (libc6,x86-64) => /usr/local/lib/libopenblas.so
	libopenblas.so (libc6,x86-64) => /usr/lib/libopenblas.so
 ldconfig -p |grep lapack
	liblapack.so.3 (libc6,x86-64) => /usr/lib/liblapack.so.3
	liblapack.so (libc6,x86-64) => /usr/lib/liblapack.so
@beauby
Copy link
Contributor

beauby commented Jun 12, 2018

  1. What does g++ --version say?
  2. What happens if you put -lopenblas -llapack at the end of the line?

i.e. g++ -std=c++11 -fopenmp -o misc/test_blas misc/test_blas.cpp -lopenblas -llapack.

@shutcode
Copy link
Author

  1. g++ version
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  1. It is OK, why?
~/faiss/misc$ g++ -std=c++11 -fopenmp -o misc/test_blas misc/test_blas.cpp -lopenblas -llapack
~/faiss/misc$ ./test_blas 
BLAS test
errors=
 0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 
 0.000 -0.000  0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000 -0.000 -0.000  0.000  0.000  0.000 
 0.000  0.000  0.000  0.000  0.000 -0.000  0.000 -0.000 -0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000 
 0.000  0.000  0.000  0.000  0.000 -0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 
 0.000  0.000  0.000  0.000 -0.000  0.000 -0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000 
 0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000 -0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000  0.000 
 0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000 -0.000 
 0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000 -0.000  0.000  0.000  0.000  0.000 
 0.000  0.000  0.000 -0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000 -0.000  0.000  0.000  0.000  0.000  0.000 
 0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000 -0.000  0.000  0.000  0.000  0.000  0.000 
Intentional Lapack error (appears only for 64-bit INTEGER):
info=0000064b00000000
Lapack uses 32-bit integers

@mdouze mdouze added the install label Jun 13, 2018
@beauby
Copy link
Contributor

beauby commented Jun 13, 2018

This is because the linker is sensitive to the order in which libraries are linked. I'll update the Makefile.
Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants