From: NM on
Hi All
I have a LAPACK library compiled with intel fortran compiler 9. I can
call the library functions from fortran. I am trying to call the LAPACK
functions from c++ and currently getting the following error. Can anyone
please help me solving the linking error? Thanks


~/temp/lapack_from_C++> g++
main.cpp -L/projects/lapack_linux -llapack_LINUX -lblas_LINUX
/projects/lapack_linux/liblapack_LINUX.a(ilaenv.o): In function `ilaenv_':
ilaenv.o(.text+0xf1): undefined reference to `for_cpystr'
ilaenv.o(.text+0x234): undefined reference to `for_cpstr'
ilaenv.o(.text+0x25b): undefined reference to `for_cpstr'
ilaenv.o(.text+0x282): undefined reference to `for_cpstr'
ilaenv.o(.text+0x2ad): undefined reference to `for_cpstr'
ilaenv.o(.text+0x2dc): undefined reference to `for_cpstr'
/projects/lapack_linux/liblapack_LINUX.a(ilaenv.o)(.text+0x32a): more
undefined references to `for_cpstr' follow
/projects/lapack_linux/liblapack_LINUX.a(xerbla.o): In function `xerbla_':
xerbla.o(.text+0x3a): undefined reference to `for_write_seq_fmt'
xerbla.o(.text+0x57): undefined reference to `for_write_seq_fmt_xmit'
xerbla.o(.text+0x6b): undefined reference to `for_stop_core'
collect2: ld returned 1 exit status


From: E. Robert Tisdale on
NM wrote:

> I have a LAPACK library compiled with intel Fortran compiler 9.
> I can call the library functions from Fortran.
> I am trying to call the LAPACK functions from C++
> and currently getting the following error.
> Can anyone please help me solving the linking error?
>
> ~/temp/lapack_from_C++> g++
> main.cpp -L/projects/lapack_linux -llapack_LINUX -lblas_LINUX
> /projects/lapack_linux/liblapack_LINUX.a(ilaenv.o): In function `ilaenv_':
> ilaenv.o(.text+0xf1): undefined reference to `for_cpystr'
> ilaenv.o(.text+0x234): undefined reference to `for_cpstr'
> ilaenv.o(.text+0x25b): undefined reference to `for_cpstr'
> ilaenv.o(.text+0x282): undefined reference to `for_cpstr'
> ilaenv.o(.text+0x2ad): undefined reference to `for_cpstr'
> ilaenv.o(.text+0x2dc): undefined reference to `for_cpstr'
> /projects/lapack_linux/liblapack_LINUX.a(ilaenv.o)(.text+0x32a): more
> undefined references to `for_cpstr' follow
> /projects/lapack_linux/liblapack_LINUX.a(xerbla.o): In function `xerbla_':
> xerbla.o(.text+0x3a): undefined reference to `for_write_seq_fmt'
> xerbla.o(.text+0x57): undefined reference to `for_write_seq_fmt_xmit'
> xerbla.o(.text+0x6b): undefined reference to `for_stop_core'
> collect2: ld returned 1 exit status

These are undefined references to Fortran subprograms (in libifcore.a).
g++ doesn't know anything about Fortran libraries
so you will need to provide that information:

~/temp/lapack_from_C++> g++ \
-L/opt/intel/compilers/ifort_9.?.???/lib \
-L/projects/lapack_linux -o main main.cpp \
-llapack_LINUX -lblas_LINUX -lifcore