[lammps-users] question about building LAMMPS as a library

Dear,
I want to Build LAMMPS( 08version ) as a library, But there are some errors. May be fftw linker interface wrong, but I don’t know how to solve it . I have run make makelib and make -f makefile.lib g++ and created the libmp_g++.a. I have checked the relative path of FFTW is right. I also tried the absolute path. The following is command, error, and makefile, I hope some kind man tell me why. Thanks in advance.

*icc -I…/…/src -I…/…/…/…/lib/fftw215/include *
*-L…/…/…/…/lib/fftw215/lib -L…/…/src c++_driver.cpp *
*-lfftw -llmp_g++ /usr/lib/libmpi++.so /usr/lib/libmpi.so -lstdc++ *
-mcpu=itanium2-p9000 -mtune=itanium2-p9000 -o c++_driver

ERROR:
…/…/src/liblmp_g++.a(fft3d.o): In function fft_1d_only(fftw_complex*, int, int, fft_plan_3d*)': fft3d.cpp:(.text+0x4d2): undefined reference to fftw’
fft3d.cpp:(.text+0x5d2): undefined reference to fftw' fft3d.cpp:(.text+0x6d2): undefined reference to fftw’
fft3d.cpp:(.text+0x962): undefined reference to fftw' fft3d.cpp:(.text+0xa62): undefined reference to fftw’
…/…/src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0xb62): more undefined references to fftw' follow ../../src/liblmp_g++.a(fft3d.o): In function fft_3d_destroy_plan(fft_plan_3d*)’:
fft3d.cpp:(.text+0x1642): undefined reference to fftw_destroy_plan' fft3d.cpp:(.text+0x1662): undefined reference to fftw_destroy_plan’
fft3d.cpp:(.text+0x1692): undefined reference to fftw_destroy_plan' fft3d.cpp:(.text+0x16b2): undefined reference to fftw_destroy_plan’
fft3d.cpp:(.text+0x16d2): undefined reference to fftw_destroy_plan' ../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x16f2): more undefined references to fftw_destroy_plan’ follow
…/…/src/liblmp_g++.a(fft3d.o): In function fft_3d_create_plan(unsigned int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int*)': fft3d.cpp:(.text+0x2c62): undefined reference to fftw_create_plan’
fft3d.cpp:(.text+0x2c82): undefined reference to fftw_create_plan' fft3d.cpp:(.text+0x2f82): undefined reference to fftw_create_plan’
fft3d.cpp:(.text+0x2fb2): undefined reference to fftw_create_plan' fft3d.cpp:(.text+0x3012): undefined reference to fftw_create_plan’
…/…/src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x3032): more undefined references to fftw_create_plan' follow ../../src/liblmp_g++.a(fft3d.o): In function fft_3d(fftw_complex*, fftw_complex*, int, fft_plan_3d*)’:
fft3d.cpp:(.text+0x3ad2): undefined reference to fftw' fft3d.cpp:(.text+0x3c62): undefined reference to fftw’
fft3d.cpp:(.text+0x3df2): undefined reference to fftw' fft3d.cpp:(.text+0x40b2): undefined reference to fftw’
fft3d.cpp:(.text+0x41b2): undefined reference to fftw' ../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x42b2): more undefined references to fftw’ follow

MAKEfile:

CC = icc
CCFLAGS = -DFFT_FFTW -DGZIP -O2 -mcpu=itanium2-p9000 -mtune=itanium2-p9000 -I…/…/…/…/lib/fftw215/include
DEPFLAGS = -M

one user needed icpc to link

LINK = icc
LINKFLAGS = -O0 -L…/…/…/…/lib/fftw215/lib
USRLIB = -lfftw
SYSLIB = /usr/lib/libmpi++.so /usr/lib/libmpi.so -lstdc++
SIZE = size

??> *Dear,*

dear "unknown",

* I want to Build LAMMPS( 08version ) as a library, But there are
  some errors. May be fftw linker interface wrong, but I don't know how
  to solve it . I have run make makelib and make -f makefile.lib g++ and
  created the libmp_g++.a. I have checked the relative path of FFTW is
  right. I also tried the absolute path. The following is command,
  error, and makefile, I hope some kind man tell me why. Thanks in
  advance.* ** *icc -I../../src -I../../../../lib/fftw215/include \*
* -L../../../../lib/fftw215/lib -L../../src c++_driver.cpp \*
* -lfftw -llmp_g++ /usr/lib/libmpi++.so /usr/lib/libmpi.so
-lstdc++ \*
* -mcpu=itanium2-p9000 -mtune=itanium2-p9000 -o c++_driver*

please note, that in linking usually the order matters (i think only
MSVC and a few other compiler/linkers handle this differently).
i.e. if a library that comes later uses a functionality that has
already been linked previously it will show up as undefined.
LAMMPS references fftw, so -lfftw has to come _after_ -llmp_xxx.

cheers,
   axel.

p.s.: please consider sending plain ASCII mails and provide
a readable name. it is very irritating to people that don't
want to install all charactersets of the known world on their
machines. thank you.

ERROR:
../../src/liblmp_g++.a(fft3d.o): In function `fft_1d_only(fftw_complex*,
int, int, fft_plan_3d*)':
fft3d.cpp:(.text+0x4d2): undefined reference to `fftw'
fft3d.cpp:(.text+0x5d2): undefined reference to `fftw'
fft3d.cpp:(.text+0x6d2): undefined reference to `fftw'
fft3d.cpp:(.text+0x962): undefined reference to `fftw'
fft3d.cpp:(.text+0xa62): undefined reference to `fftw'
../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0xb62): more undefined
references to `fftw' follow
../../src/liblmp_g++.a(fft3d.o): In function
`fft_3d_destroy_plan(fft_plan_3d*)':
fft3d.cpp:(.text+0x1642): undefined reference to `fftw_destroy_plan'
fft3d.cpp:(.text+0x1662): undefined reference to `fftw_destroy_plan'
fft3d.cpp:(.text+0x1692): undefined reference to `fftw_destroy_plan'
fft3d.cpp:(.text+0x16b2): undefined reference to `fftw_destroy_plan'
fft3d.cpp:(.text+0x16d2): undefined reference to `fftw_destroy_plan'
../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x16f2): more undefined
references to `fftw_destroy_plan' follow
../../src/liblmp_g++.a(fft3d.o): In function `fft_3d_create_plan(unsigned
int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
int, int, int, int*)':
fft3d.cpp:(.text+0x2c62): undefined reference to `fftw_create_plan'
fft3d.cpp:(.text+0x2c82): undefined reference to `fftw_create_plan'
fft3d.cpp:(.text+0x2f82): undefined reference to `fftw_create_plan'
fft3d.cpp:(.text+0x2fb2): undefined reference to `fftw_create_plan'
fft3d.cpp:(.text+0x3012): undefined reference to `fftw_create_plan'
../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x3032): more undefined
references to `fftw_create_plan' follow
../../src/liblmp_g++.a(fft3d.o): In function `fft_3d(fftw_complex*,
fftw_complex*, int, fft_plan_3d*)':
fft3d.cpp:(.text+0x3ad2): undefined reference to `fftw'
fft3d.cpp:(.text+0x3c62): undefined reference to `fftw'
fft3d.cpp:(.text+0x3df2): undefined reference to `fftw'
fft3d.cpp:(.text+0x40b2): undefined reference to `fftw'
fft3d.cpp:(.text+0x41b2): undefined reference to `fftw'
../../src/liblmp_g++.a(fft3d.o):fft3d.cpp:(.text+0x42b2): more undefined
references to `fftw' follow

MAKEfile:

CC = icc
CCFLAGS = -DFFT_FFTW -DGZIP -O2 -mcpu=itanium2-p9000 -mtune=itanium2-p9000
-I../../../../lib/fftw215/include
DEPFLAGS = -M

# one user needed icpc to link

LINK = icc
LINKFLAGS = -O0 -L../../../../lib/fftw215/lib
USRLIB = -lfftw
SYSLIB = /usr/lib/libmpi++.so /usr/lib/libmpi.so -lstdc++
SIZE = size