C How to link with lapacke?

I'm trying to compile the following file:

Code:
#include <lapacke.h>
int main() {
   LAPACKE_dgelsy(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

Following some dependencies hunt I figured out that the following libraries are needed:

Code:
$ c++ fail.cpp -isystem /usr/local/include/ -L/usr/local/lib -llapacke -llapack -lblas -ltmglib

But unfortunately I still can't find where to get these symbols from:

Code:
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__getf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__floatunditf@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__subtf3@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__multf3@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__lttf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__addtf3@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__gttf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__divtf3@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__letf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__netf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__floatditf@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__eqtf2@GCC_4.6.0'
//usr/local/lib/gcc49/libgfortran.so.3: undefined reference to `__floatsitf@GCC_4.6.0'
c++: error: linker command failed with exit code 1 (use -v to see invocation)

Extensive web search reveals only repeating reports of similar problem but no solution.

So, what libraries do I need to link with?

System: RELEASE-11.0 with up-to-date binary packages.
 
AFAICT you need to link with libquadmath. It's only available in lang/gcc. I can link your example with
c++ fail.cpp -isystem /usr/local/include/ -L/usr/local/lib -L/usr/local/lib/gcc49 -lquadmath -llapacke -llapack -lblas -ltmglib

But I think it's probably better to use g++ instead of c++ which will do this for you:
g++ fail.cpp -isystem /usr/local/include/ -Wl,-rpath=/usr/local/lib/gcc49 -L/usr/local/lib -llapacke -llapack -lblas -ltmglib
 
AFAICT you need to link with libquadmath. It's only available in lang/gcc. I can link your example with
c++ fail.cpp -isystem /usr/local/include/ -L/usr/local/lib -L/usr/local/lib/gcc49 -lquadmath -llapacke -llapack -lblas -ltmglib

This isn't true, I managed to link without -lquadmath.

But I think it's probably better to use g++ instead of c++ which will do this for you:
g++ fail.cpp -isystem /usr/local/include/ -Wl,-rpath=/usr/local/lib/gcc49 -L/usr/local/lib -llapacke -llapack -lblas -ltmglib

Thanks but I prefer compiling with clang.

I think that you need add this parameters to your command line:
-L/usr/local/lib/gcc49 -Wl,-rpath=/usr/local/lib/gcc49

Thanks, this did it!
 
Back
Top