views:

264

answers:

2

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'
+2  A: 

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

Dave Gamble
@DG: Thanks. But it still give the same error.
neversaint
@DG: Thanks again. Now it recognize the lib. Any idea what's the possible cause of new error (see update)?
neversaint
+2  A: 

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.

Eugene
If you check the ls, it's in CWD and he's -L .
Dave Gamble
@Eugene: I didn't install anything I just download that "so" file. From here: http://pardiso-project.org/download/ab6ex6hze7cvjhuz04/
neversaint
Yeah, I saw that later :). Try -L. without a space though.
Eugene
@Eugene: Thanks but, now it gives only this error:/usr/local/bin/ld: cannot find -lg2ccollect2: ld returned 1 exit status
neversaint
What distro do you use? Search for gcc-g77 in your distro's repository.
Eugene
@Eugene: cat /proc/version Linux version 2.6.16.60-0.21-default (geeko@buildhost) (gcc version 4.1.2 20070115 (SUSE Linux)) #1 SMP Tue May 6 12:41:02 UTC 2008I have specified a path to lg2c, although no avail: http://dpaste.com/78082/
neversaint
TL;DR -- try -llapack -lg2c -lgfortran -lpthread
Eugene