Specify dependencies with more details because of errors at linking
Closed this issue · 5 comments
Hello,
I am trying to install bmagwa
on a computer cluster with the following software and libraries:
- gcc/4.9.2
- boost/1_58_0
- binutils/2.25
- OpenBLAS/0.2.18
- lapack/3.5.0
The first four are made available via environment modules. For the last one, I modified the LDFLAGS of the makefile, like this:
LDFLAGS=-L/usr/local/bioinfo/lapack/3.5.0/lib -lblas -llapack -lpthread -lgfortran -lrt
Everything compiles successfully. However, I get the following error at linking:
g++ src/data.cpp.o src/data_model.cpp.o src/main.cpp.o src/matrix.cpp.o src/model.cpp.o src/prior.cpp.o src/sampler.cpp.o src/symmmatrix.cpp.o src/utils.cpp.o src/vector.cpp.o src/inih/cpp/INIReader.cpp.o src/inih/ini.c.o src/dchex.f.o -o bmagwa -L/usr/local/bioinfo/lapack/3.5.0/lib -lblas -llapack -lpthread -lgfortran -lrt
src/main.cpp.o: In function `bmagwa::PrecomputedSNPCovariances::precompute(bmagwa::DataModel const*)':
main.cpp:(.text._ZN6bmagwa25PrecomputedSNPCovariances10precomputeEPKNS_9DataModelE[_ZN6bmagwa25PrecomputedSNPCovariances10precomputeEPKNS_9DataModelE]+0x123): undefined reference to `cblas_ddot(int, double const*, int, double const*, int)'
The cblas_ddot
function can't be found. In which library should this function be found? Lapack or OpenBlas? Are my libraries recent enough? Am I missing a library?
Hi,
I think it should be in OpenBLAS.
You could try changing the -lblas flag to -lopenblas and, if that alone does not work, add explicit path to the openblas library (e.g., -L../OpenBLAS-0.2.18/). In addition or instead, you can try removing -llapack and the lapack path from LDFLAGS. It might be that OpenBLAS contains all of LAPACK that is needed.
I just tried compiling on OS X and it worked without lapack-flags, although I had to make some other changes to get everything to compile. It seems that I should update the makefile and the code, but if compilation was successful for you, then, hopefully, some adjustments to the LDFLAGS will solve the problem.
Changing -lblas -llapack
to -lopenblas -llapack
decreases the number of undefined references
from 21 to 12 (for instance, undefined reference to dpotrf_
disappears). However, undefined reference to cblas_ddot
still remains, along with others, such as undefined reference to cblas_dsyrk
.
Keeping or removing -llapack
, with or without -L<...>/lapack/3.5.0
, with or without -L<...>/OpenBLAS/0.2.18
, doesn't change anything.
Replacing -llapack
with -latlas
doesn't change anything. I'm out of options here...
That's a typical case where I would guess that using GNU Build System would make things easier.
Thanks for trying. I'm sorry that it's not working.
One final thing to try would be to compile openblas yourself (it's easy; just download openblas and run make
in the openblas directory; no need to install it further) and add -I/path/to/OpenBLAS-0.2.18/
to CXXFLAGS and -L/path/to/OpenBLAS-0.2.18/
to LDFLAGS and use -lopenblas
. In addition, you might have to comment out the lines (add //
to start of the lines) near the top of src/symmmatrix.hpp
if the compilation fails on multiple definitions of dpotrf_
:
extern "C" void dpotrf_(char *uplo, int *n, double *a, int *lda,
int *info); // cholesky
But this is just guessing (although openblas should have those functions) and I might end up just wasting your time with these instructions, so I understand if you don't want to use your time on this.
I know the build process is not very well refined. Unfortunately, I don't think I will have time to update it in the next few weeks at least, since it will require me learning about the build systems etc. Thanks for the pointer.
I finally did it! It turns out that it only works with these exact lines:
CXXFLAGS=-I/usr/local/bioinfo/OpenBLAS/0.2.18/include -DNDEBUG -O3 -march=native -Wall -c
LDFLAGS=-L/usr/local/bioinfo/OpenBLAS/0.2.18/lib -lopenblas -llapack -lpthread -lgfortran -lrt
that is, one needs to write -I/usr/local/bioinfo/OpenBLAS/0.2.18/include
and not only -I/usr/local/bioinfo/OpenBLAS/0.2.18
. Don't ask me why ;)
Moreover, -llapack
isn't required to compile successfully.
Maybe you could add a few more details in the README.markdown
? (by the way, it's enough to name it REAMDE.md
).
Anyway, thanks first for providing your code under the GPL, then for versioning it with git and hosting it on GitHub, and third for your help. I'll let you know if I encounter any other problem (hope not).
That's great!
Thanks for reporting back and detailing the solution. I should certainly update the whole build set-up (and some of the code as compilation with the current github version fails for some systems, at least OS X, and small changes are needed to fix it).