Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-01-2014, 02:36 PM   #1
LQ Newbie
Registered: Jul 2014
Posts: 3

Rep: Reputation: Disabled
Liblapacke linker errors : eigenvectors computing

Hi there !
I'm very new to this forum, but I have been reading it for quite a long time. As I always found the answers to what I was looking for, I never had to register, but this time is OVER, and this is all due to the LAPACK lib that makes me want to crush my computer into pieces.

Anyway, let's get to it :

I'm developping some math heavy C++ software using matrices, where I need to compute eigenvectors on a big symetric non-sparse matrix (currently 500x500, but it will be something like 10000x10000 later).
As I use Point CLoud Library, which is shipped with the Eigen lib, I tried using its eigenvectors algorithm, but the result is really slow : ~5min to compute the vectors. Furthermore, it computes all 500 eigenvectors, whereas I would only need the 5 or 10 most important ones.

I know Matlab eig(...) function works really well, and I saw it used LAPACK algorithm. But I started crying when I learned the LAPACK library was coded in Fortran.

Currently working on a Mint 15 x64, I saw liblapacke-dev in the repository, and installed it. It came alongside with libblas3, libblas-dev, liblapack3, liblapack-dev, and liblapacke .

Now here's a test program :
#include <iomanip>
#include <iostream>
#include <cstdlib>
#include <cblas.h>
#include <lapacke.h>

using namespace std;

int main(int argc, char** argv) {
	char jobz = 'V';
	char uplo = 'U';
	int n = 3;
	int lda = n;
	int matrix_order = n;
	float *a, *w;
	a = new float[n * n];
	w = new float[n];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			a[i*n + j] = rand() % 10 / 10.f;
			a[j*n + i] = a[i*n + j];
	LAPACKE_ssyev(matrix_order, jobz, uplo, n, a, lda, w);
	return 0;
And here is my compile line and its output :
$ g++  -o lapacke_test -llapacke -llapack -lblas -g -Wall main.cpp
/tmp/ccYj3pGz.o: In function `main':
/pat_to_my_code/main.cpp:27: undefined reference to `LAPACKE_ssyev'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
I tried adding -L/usr/lib/ or -L/usr/lib/liblapacke.a or -L/usr/lib/liblapack.a (and .so), didn't work (the files are there). the lapacke.h file and its friends are also in /usr/include .
I also tried calling ldconfig, just in case.
The linker is always so mean to me ! Why ?!

Still, in my wraith I uninstalled all the packages I listed above, and tried to compile LAPACK on my own. I used cmake, installed gfortran, generated the makefiles ok, but then came a looooong list of undefined references :
[  2%] Built target tmglib
Linking Fortran executable ../../bin/xlintstc
CMakeFiles/xlintstc.dir/cchkhe_rook.f.o: In function `cchkhe_rook_':
cchkhe_rook.f:(.text+0x8db): undefined reference to `chetrf_rook_'
cchkhe_rook.f:(.text+0xbba): undefined reference to `chetri_rook_'
cchkhe_rook.f:(.text+0x1d03): undefined reference to `chetrs_rook_'
cchkhe_rook.f:(.text+0x21b3): undefined reference to `checon_rook_'
CMakeFiles/xlintstc.dir/cchksy_rook.f.o: In function `cchksy_rook_':
cchksy_rook.f:(.text+0x926): undefined reference to `csytrf_rook_'
cchksy_rook.f:(.text+0xc05): undefined reference to `csytri_rook_'
cchksy_rook.f:(.text+0x1ffe): undefined reference to `csytrs_rook_'
cchksy_rook.f:(.text+0x24ae): undefined reference to `csycon_rook_'
CMakeFiles/xlintstc.dir/cdrvhe_rook.f.o: In function `cdrvhe_rook_':
cdrvhe_rook.f:(.text+0x8c4): undefined reference to `chetrf_rook_'
cdrvhe_rook.f:(.text+0x969): undefined reference to `chetri_rook_'
cdrvhe_rook.f:(.text+0xc75): undefined reference to `chesv_rook_'
I find so little documentation on this lib, plus I don't know anything about Fortran (and was very happy with that). If anybody has a suggestion to set it right, it would make my day.
For example, if you know any eigenvectors algorithm to retreive only the most important ones, that could be paralellized (I have good clusters at work), that don't require to install libraries from the Ancient Times, that would be great !

Thanks !

EDIT : I did finally manage to compile LAPACKE with LAPACK + BLAS using cmake, but the error I get is still the same. I really don't know how to fix this.

Last edited by Luxey; 07-02-2014 at 10:32 AM.
Old 07-05-2014, 05:44 AM   #2
Tim Abracadabra
Registered: May 2014
Location: USA, Wherever I may Roam
Distribution: Debian w/Xfce, LFS 7.9, ++
Posts: 117

Rep: Reputation: Disabled
Hi Luxey and Welcome.

Please forgive me if I am misinterpreting your question or code but:

Did you consider adjusting your source?

"LAPACKE_ssyev(matrix_order, jobz, uplo, n, a, lda, w);"

You might want to google the Fortran/Linear Algebra lib alternatives and see if they suit your needs, or just use an appropriate C(++) lib.

Maybe this link to C Interface Conventions helps?

Just my $0.02 !

Hope that helps,

Last edited by Tim Abracadabra; 07-05-2014 at 06:40 AM. Reason: Highlight where source change may be made


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] cryptic linker error (i really dont like linker errors); smeezekitty Programming 2 09-19-2009 03:21 AM
c++ linker errors kpachopoulos Programming 3 01-22-2007 05:02 AM
ld linker errors Ankit mittal Programming 1 09-30-2005 04:05 PM
linker errors -please help MarcReing Programming 1 07-20-2005 08:44 AM
Linker errors daveyboy685 Linux - Software 1 03-25-2004 01:25 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:39 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration