Problem to build lammps as a Library and called by another code

Hi

I was trying to build lammps as a library. I have installed lammps in my system. The OS is Feroda15. I have also installed FFTW3 and MPICH for my system. Lammps is installed and it is working fine. For compilation of lammps as a library I have used the following steps:

  1. In in lammps src directory I did 1st

make makelib
make -f Makefile.lib linux

Then liblammps_linux.a file is generated in the src directory.

  1. Then i was trying to use LAMMPS as a library called by another code that is given in exmple/COUPLE/Simple. Here i used the following steps:

i) g++ -I/home/atanu/lammps-14May13/src -c simple.cpp. it gives simple.cpp:25:17: fatal error: mpi.h: No such file or directory

#ii)g++ -I/home/atanu/MPI/mpich-install/include/ -I/home/atanu/lammps 14May13/src -c simple.cpp

During my compilation it showing:

simple.cpp: In function ‘int main(int, char**)’:
simple.cpp:108:38: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
simple.cpp:111:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

and I got the simple.o file

#ii) final step
g++ -L/home/atanu/lammps 14May13/src/ simple.o -llmp_linux -lfftw3 -lmpich -lmpl -lpthread -o simpleCC

The error is g++: error: 14May13/src/: No such file or directory

I’d be thankful if you tell me how to do .

Thanks in advance,

Atanu K Metya

Comments below.

Steve

Hi

I was trying to build lammps as a library. I have installed lammps in my
system. The OS is Feroda15. I have also installed FFTW3 and MPICH for my

fedora 15 is *very* outdated. recent versions work extremely well for
parallel development and have nice bundled rpm for up-to-date versions
of both OpenMPI (which is in my personal opinion preferable to MPICH)
and MPICH.

system. Lammps is installed and it is working fine. For compilation of
lammps as a library I have used the following steps:

1) In in lammps src directory I did 1st
make makelib
make -f Makefile.lib linux

Then liblammps_linux.a file is generated in the src directory.

2) Then i was trying to use LAMMPS as a library called by another code that
is given in exmple/COUPLE/Simple. Here i used the following steps:

# i) g++ -I/home/atanu/lammps-14May13/src -c simple.cpp. it gives
simple.cpp:25:17: fatal error: mpi.h: No such file or directory

when compiling MPI code, you should use "mpiCC" or "mpicxx" instead of
g++, so that the compiler finds the necessary (and correct) include
files.

#ii)g++ -I/home/atanu/MPI/mpich-install/include/ -I/home/atanu/lammps
14May13/src -c simple.cpp
During my compilation it showing:

simple.cpp: In function ‘int main(int, char**)’:
simple.cpp:108:38: warning: deprecated conversion from string constant to
‘char*’ [-Wwrite-strings]
simple.cpp:111:39: warning: deprecated conversion from string constant to
‘char*’ [-Wwrite-strings]

those are warning and irrelevant.

and I got the simple.o file

#ii) final step
g++ -L/home/atanu/lammps 14May13/src/ simple.o -llmp_linux -lfftw3 -lmpich
-lmpl -lpthread -o simpleCC

The error is g++: error: 14May13/src/: No such file or directory

that is because you have two blanks in your command line that don't
belong there and are missing a '/'.

I'd be thankful if you tell me how to do .

if you use the compiler correctly, it will work.

axel.

Dear Steve,

Thanks for your reply. Yes you are right the name of LAMMPS lib file in the src directory is liblammps_linux.a. Then I did the following commands

g++ -L/home/atanu/lammps 14May13/src/ simple.o -lliblammps_linux.a -lfftw3 -lmpich -lmpl -lpthread -o simpleCC
g++: error: 14May13/src/: No such file or directory
g++ -L/home/atanu/lammps 14May13/src/ simple.o -llammps_linux.a -lfftw3 -lmpich -lmpl -lpthread -o simpleCC
g++: error: 14May13/src/: No such file or directory
g++ -L/home/atanu/lammps 14May13/src simple.o -lliblammps_linux.a -lfftw3 -lmpich -lmpl -lpthread -o simpleCC
g++: error: 14May13/src: No such file or directory
g++ -L/home/atanu/lammps 14May13/src simple.o -llammps_linux.a -lfftw3 -lmpich -lmpl -lpthread -o simpleCC
g++: error: 14May13/src: No such file or directory

Thank You.

With best regards,

Atanu

Dear Axel,

I was trying to build lammps as a library in our cluster. During compilation of code (simple.cpp given in example file) i got the message
ld: cannot find -lfftw ( lammps executable build with fftw)

If I build lammps executable with out fftw then there was no message.

During compilation of LAMMPS I did the following changes in Makefile.mkl file

compiler/linker settings

specify flags and libraries needed for your compiler

CC = mpicc
CCFLAGS = -O3 -fno-alias -ip -unroll0
SHFLAGS = -fPIC
DEPFLAGS = -M

LINK = mpicc
LINKFLAGS = -O -L/opt/intel/Compiler/11.1/046/mkl/lib/em64t -L/apps/intel/Compiler/11.1/046/lib/intel64
LIB = -lstdc++ -lpthread -lmkl_core -lmkl_intel_lp64 -lmkl_sequential -lguide -limf
SIZE = size

FFT library

FFT_INC = -DFFT_FFTW -I/opt/intel/Compiler/11.1/046/mkl/include/fftw
FFT_PATH =
FFT_LIB = /opt/intel/Compiler/11.1/046/mkl/lib/em64t/libfftw2xc_intel.a

After that I got lmp_mkl executable with out any message.

Then I have used following command to build lammps as a library

make makelib

make -f Makefile.lib mkl
liblammps_mkl.a file generated.

Then I was trying in the example file the simple.cpp program. I used following command

  1. mpicc -I /home/atanu/SOFTWARE/lammps23Sep13/src -c simple.cpp -O3

simple.o file is generated and the final step

mpicc -L /home/atanu/SOFTWARE/lammps23Sep13/src simple.o -lfftw -lstdc++ -lpthread -lmkl_core -lmkl_intel_lp64 -lmkl_sequential -lguide -limf -llammps_mkl

The message is : ld: cannot find -lfftw

I’d be thankful if you tell me how to do .

Thanks in advance,

Atanu K Metya

Dear Axel,

I was trying to build lammps as a library in our cluster. During compilation
of code (simple.cpp given in example file) i got the message
ld: cannot find -lfftw ( lammps executable build with fftw)

sorry, i don't run a class in basic makefile writing and compiling
here. these are trivial issues. find somebody local that knows more
about compilers and compiling than you and figure it out together.

axel.

try changing fftw by fftw3 in the Makefile and see what happens