Problem with Lammps/Example/Couple/Simple

Hi Lammps-Users,
I am Conor O’Donnell from University College Dublin and I working on a cecam project to interface lammps with a Quantum Path Sampling Code which my supervisor, Dr. Donal MacKrenan, has created. However, to begin I am looking at the simple interfacing example that is provided with lammps however I cannot seem to get it to work even though I am following the steps included in the provided read me file.

This command runs fine:
mpiCC -I/home/sjplimp/lammps/src -c simple.cpp

However once I run:
mpiCC -L/home/sjplimp/lammps/src simple.o -llammps -lfftw -o simpleCC

I get the following error

/usr/bin/x86_64-linux-gnu-ld: cannot find -llammps
/usr/bin/x86_64-linux-gnu-ld: cannot find -lfftw
collect2: error: ld returned 1 exit status

And if I remove the -llammps and -lfftw flags and repeat the command I receive the following error:

simple.o: In function main': simple.cpp:(.text+0x1b6): undefined reference to LAMMPS_NS::LAMMPS::LAMMPS(int, char**, ompi_communicator_t*)’
simple.cpp:(.text+0x2a8): undefined reference to lammps_command' simple.cpp:(.text+0x2eb): undefined reference to LAMMPS_NS::Input::one(char const*)’
simple.cpp:(.text+0x398): undefined reference to lammps_gather_atoms' simple.cpp:(.text+0x3c2): undefined reference to lammps_gather_atoms’
simple.cpp:(.text+0x41a): undefined reference to lammps_scatter_atoms' simple.cpp:(.text+0x434): undefined reference to LAMMPS_NS::Input::one(char const*)’
simple.cpp:(.text+0x45e): undefined reference to lammps_extract_atom' simple.cpp:(.text+0x4af): undefined reference to lammps_extract_variable’
simple.cpp:(.text+0x510): undefined reference to lammps_commands_string' simple.cpp:(.text+0x550): undefined reference to lammps_commands_list’
simple.cpp:(.text+0x60c): undefined reference to LAMMPS_NS::Input::one(char const*)' simple.cpp:(.text+0x648): undefined reference to lammps_create_atoms’
simple.cpp:(.text+0x666): undefined reference to LAMMPS_NS::Input::one(char const*)' simple.cpp:(.text+0x6c5): undefined reference to LAMMPS_NS::LAMMPS::~LAMMPS()’
collect2: error: ld returned 1 exit status

If this question is extremely obvious could you please point me towards the related documentation as I have looked through the lammps documentation manual and this mailing list and have found no useful information. Also if you could point me towards the C++ interfacing documentation I would be grateful as again I cannot find a good source of information.

Thank you in advance.
Kind Regards,
Conor O’Donnell.

Hi Lammps-Users,
I am Conor O’Donnell from University College Dublin and I working on a cecam project to interface lammps with a Quantum Path Sampling Code which my supervisor, Dr. Donal MacKrenan, has created. However, to begin I am looking at the simple interfacing example that is provided with lammps however I cannot seem to get it to work even though I am following the steps included in the provided read me file.

This command runs fine:
mpiCC -I/home/sjplimp/lammps/src -c simple.cpp

However once I run:
mpiCC -L/home/sjplimp/lammps/src simple.o -llammps -lfftw -o simpleCC

I get the following error

/usr/bin/x86_64-linux-gnu-ld: cannot find -llammps
/usr/bin/x86_64-linux-gnu-ld: cannot find -lfftw
collect2: error: ld returned 1 exit status

And if I remove the -llammps and -lfftw flags and repeat the command I receive the following error:

​well, did you successfully build the liblammps_machine.a file (and the liblammps.a symlink) in the src folder as indicated in the README?
in general, it is recommended to first build a working LAMMPS executable (so you can test your inputs), and then the matching library using the mode=lib setting. ​

​what additional libraries you need (like -lfftw) depends on your machine makefile settings and which packages you install/enable. with the recommended default machines (mpi or serial), you won’t need -lfftw.​

​axel.​