Reputation: 919
I have several files which I need to compile together as following in my makefile (names are dummy now):
compile:
g++ prog1.cpp func1.cpp func2.cpp func3.cpp -L/usr/lib/ -lmkl_lapack64 -lmkl
-lguide -lpthread -o output_ready.out
When I do make compile, then I get the following errors:
/usr/bin/ld: cannot find -lmkl_lapack64
/usr/bin/ld: cannot find -lmkl
/usr/bin/ld: cannot find -lguide
collect2: ld returned 1 exit status
make: *** [compile] Error 1
This program was correctly compiled in another machine previously.
Q: How can I check the path for lapack lib if they are correct? How should I fix them? The libraries are installed (not sure if with the right path).
Any helpful comment is highly appreciated. R
Upvotes: 1
Views: 3191
Reputation: 400
An excellent way to find the correct compiler and linker flags based on your OS, architecture, etc. is using the Intel online tool, which you can find here:
https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor.
To access it, you need to login to the Intel website.
Upvotes: 0
Reputation: 1013
First of all I would have suggested you to check if libraries are installed in correct directories, as you planned yourself. An obvious way to do this is just to cd /usr/lib
and see whether there are any lapack libraries (you will notice them at once).
If everything is installed where it should have been, I would suggest you to compile with
-I /usr/local/include/lapackpp/
for headers, and
-L /usr/local/lib -llapackpp
for libraries, as all lapack libraries should be accessed through it.
Also, are you sure you want to look for libraries in /usr/lib
, but not in /usr/local/lib
? I guess this is OS/settings specific, though.
Finally, some time ago I have had similar problem to the one you have and found a good and explicit explanation on this website. :-)
Upvotes: 1
Reputation: 8160
I don't think you need -L/usr/lib
as I believe the compiler already knows to look there for libraries. That said, you do need -L<path to where lapack libraries are>
if they were not installed in a standard location.
Upvotes: 1
Reputation: 24626
The only path where he looks for the lapack libs is /usr/lib
- since that's the only dircetory you specified for the linker. If the libs are installed in another location you will have to find it out and
-L
parameter,/usr/lib
so the linker can find the libs.
Upvotes: 1