neversaint
neversaint

Reputation: 64024

Compiling PARDISO linear solver test case with GCC

I am trying to compile a linear system solver using PARDISO. The test case (pardiso_sym.c) also downloaded from the same website above.

I have the following files inside the directory:

[gv@emerald my-pardiso]$ ls -lh
total 1.3M
-rw-r--r-- 1 gv hgc0746 1.3M Aug  7 11:59 libpardiso_GNU_IA64.so
-rw-r--r-- 1 gv hgc0746 7.2K Nov 13  2007 pardiso_sym.c

Then I try to compile it with the following command:

[gv@emerald my-pardiso]$ gcc pardiso_sym.c -o pardiso_sym -L . -llibpardiso_GNU_IA64.so -L/home/gv/.boost/include/boost-1_38 -llapack

But it gives this error:

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../x86_64-unknown-linux-gnu/bin/ld:
cannot find -llibpardiso_GNU_IA64.so
collect2: ld returned 1 exit status

What's wrong with my compilation method?

This is the additional info of my system:

[gv@emerald my-pardiso]$ uname -a
Linux gw05 2.6.18-92.1.13.el5 #1 SMP Wed Sep 24 19:32:05 EDT 2008
x86_64 x86_64 x86_64 GNU/Linux

[gv@emerald my-pardiso]$ gcc --version
gcc (GCC) 4.3.2

Update:

The library is recognized using Dave Gamble's suggestion. But now it gives different error:

$ gcc pardiso_sym.c -o pardiso_sym -L . -lpardiso_GNU_IA64 -L/home/gv/.boost/include/boost-1_38 -llapack
./libpardiso_GNU_IA64.so: undefined reference to `s_stop'
./libpardiso_GNU_IA64.so: undefined reference to `s_wsfe'
./libpardiso_GNU_IA64.so: undefined reference to `e_wsfe'
./libpardiso_GNU_IA64.so: undefined reference to `z_abs'
./libpardiso_GNU_IA64.so: undefined reference to `s_cat'
./libpardiso_GNU_IA64.so: undefined reference to `s_copy'
./libpardiso_GNU_IA64.so: undefined reference to `do_fio'

Upvotes: 2

Views: 1915

Answers (2)

Eugene
Eugene

Reputation: 7258

EDIT: For new errors you'll need -lg2c after -lapack (fortran compatibility library)

EDIT2: Also add -lgfortran and anything else you might need. Googling for a missing symbol usually finds mentions of library it contains. Keep adding libraries one by one untill all dependencies are satisfied.

So in your case routine is like this:

linked lapack -- got unresolved symbol from g2c

added g2c -- got symbols from gfortran

added gfortran -- got some other symbols, look them up and add libs one by one.

Libray order matters, if you include g2c before lapak for example, linker will throw away all its symbols before it knows they are needed for lapak (MS linker does 2 passes to fix that). So if you see a missing symbol that is in a lib you already include, look at which library needs it and move the lib with the symbol to be after it.

Upvotes: 2

Dave Gamble
Dave Gamble

Reputation: 4174

EDIT: I read the pardiso manual. Here's the fix:

gcc pardiso_sym.c -o pardiso_sym -L . -lpardiso_GNU_IA64 -L/home/gv/.boost/include/boost-1_38 -llapack

Here I've removed the "lib" from the start and the ".so" from the end of -lpardiso_GNU_IA64

Upvotes: 4

Related Questions