couple lammps

Dear all,

I want use lammps as external library in my C++ code and also I need MEAM library. I did “make” liblmp_g++.a (and meam package is installed) but compile the code interrupted by errors that “Undefined reference to MEAM functions …”. Also I try with include libmeam.a (-lmeam) but I had same errors. Could you pleas help me?

Regards,
Hamed

If you do these steps, which one fails?

a) make foo
b) make makelib
c) make -f Makefile.lib foo
d) build your app linked against LAMMPS

If you can't do a) with MEAM, then none of the rest will work.

Steve

a) make g++ had no error and lmp_g++ is constructed (and make yes-meam).
b) it’s ok.
c)it’s ok;
d) then I comiple my code by:
g++ -I /home/sadra/Packages/lammps-17Feb12/src -c lmp_hess.cpp
g++ -L /home/sadra/Packages/lammps-17Feb12/src lmp_hess.o -llmp_g++ -lfftw -lmpich -lpthread -lmpich -lmpl -lpthread -ljpeg -o lmp_hessCC

and I had errors:
“/home/sadra/Packages/lammps-17Feb12/src/liblmp_g++.a(pair_meam.o): In function ~PairMEAM': /home/sadra/Packages/lammps-17Feb12/src/Obj_g++/pair_meam.cpp:78: undefined reference to meam_cleanup_’ …”

Did I have any mistak?

regards,
Hamed

On the last step you also have to link with the MEAM lib, just
as LAMMPS does in step (a) when it builds as an application.

The libmeam.a file is in lammps/lib/meam. And you will need
whatever auxiliary Fortran libs that MEAM requires, just as LAMMPS
does. Those are listed in lib/meam/Makefile.lammps.

A lib file, like the LAMMPS library when you build it as such,
does not contain other libraries.

Steve

I tried it before:
g++ -I /home/sadra/Packages/lammps-17Feb12/src -I /home/sadra/Packages/lammps-17Feb12/lib/meam -c lmp_hess.cpp
g++ -L /home/sadra/Packages/lammps-17Feb12/src -L /home/sadra/Packages/lammps-17Feb12/lib/meam lmp_hess.o -lgfortran -lmeam -llmp_g++ \

-lfftw -lmpich -lpthread -lmpich -lmpl -lpthread -ljpeg -o lmp_hessCC

But I have same eror.

I tried it before:
g++ -I /home/sadra/Packages/lammps-17Feb12/src -I
/home/sadra/Packages/lammps-17Feb12/lib/meam -c lmp_hess.cpp
g++ -L /home/sadra/Packages/lammps-17Feb12/src -L
/home/sadra/Packages/lammps-17Feb12/lib/meam lmp_hess.o -lgfortran -lmeam
-llmp_g++ \
-lfftw -lmpich -lpthread -lmpich -lmpl -lpthread -ljpeg -o lmp_hessCC

But I have same eror.

the order of the libraries matters. you have to put the meam library
*after* the lammps library.

axel

Thank you. the order was the problem!

regards,
hamed