Thank you guys. I got it to work in both Python and and C++. Even though it is explained in the LAMMPS manual, I had some difficulty interpreting all the computer lingo.
I will post my solutions for others who also don't have experience with makefiles and linking libraries.
For Python,
1) I built LAMMPS as a shared library with the bash command "make mode=shlib ompi_g++" in the LAMMPS /src directory. The "ompi_g++" is just the particular machine I wanted, "serial" or any others will work as well. This makes a shared object file "liblammps_ompi_g++.so" and the link "liblammps.so", which links to "liblammps_ompi_g++.so".
2) I then copied both shared object files to my /usr/lib folder, where my system reads all of my shared object files (this may be different for other Linux users, but there is a nice description of how to change the path in the LAMMPS manual for Python).
3) I can now use LAMMPS in a python session with the bash command "python test.py", which calls python to run a python script. An example script is:
from lammps import lammps
lmp = lammps("in.lj")
lmp = lammps("in.lj")
lmp = lammps("in.lj")
This basically just runs the input script 3 times during the same instance of LAMMPS. You might need to use the "pre" and "post" run commands to accommodate your needs.
For C++,
1) Same as step 1 for Python.
2) Copy the simple.cpp example in /Examples/COUPLE to the LAMMPS /src directory so that it can find all the necessary files for compilation.
3) Compile simple.cpp with "mpicxx -o simpleCC simple.cpp liblammps.so", which will make the executable "simpleCC". There are also other g++ commands which let you use a shared library in another directory, but I've just decided to compile this in the LAMMPS /src directory for simplicity. Play around with the code to change it to your needs, using functions from "library.cpp" if needed.
An example script is:
#include "mpi.h"
#include "lammps.h"
#include "input.h"
#include "string.h"
using namespace LAMMPS_NS;
/* ----------------------------------------------------------------------
main program to drive LAMMPS
------------------------------------------------------------------------- */
char *args1[] = {
(char *) "lammps1",
(char *) "-log",
(char*) "log.lammps-1",
0};
int main(int argc, char **argv)
{
MPI_Init(&argc,&argv);
LAMMPS *lammps1;
lammps1 = new LAMMPS(3,args1,MPI_COMM_WORLD);
lammps1->input->file("in.lj");
lammps1->input->file("in.lj");
lammps1->input->file("in.lj");
lammps1->input->file("in.lj");
lammps1->input->file("in.lj");
delete lammps1;
MPI_Finalize();
}
This just runs LAMMPS 5 times while keeping the same instance running.
I hope this helps others who are unfamiliar with makefiles and linking libraries.