Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
multiscale
lammps
Commits
76289cd9
Commit
76289cd9
authored
6 years ago
by
Richard Berger
Browse files
Options
Downloads
Patches
Plain Diff
Add LAMMPS shared library instructions for CMake
parent
edb535d3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/src/Python_shlib.txt
+39
-1
39 additions, 1 deletion
doc/src/Python_shlib.txt
with
39 additions
and
1 deletion
doc/src/Python_shlib.txt
+
39
−
1
View file @
76289cd9
...
@@ -9,6 +9,8 @@ Documentation"_ld - "LAMMPS Commands"_lc :c
...
@@ -9,6 +9,8 @@ Documentation"_ld - "LAMMPS Commands"_lc :c
Build LAMMPS as a shared library :h3
Build LAMMPS as a shared library :h3
Build LAMMPS as a shared library using make :h4
Instructions on how to build LAMMPS as a shared library are given on
Instructions on how to build LAMMPS as a shared library are given on
the "Build_basics"_Build_basics.html doc page. A shared library is
the "Build_basics"_Build_basics.html doc page. A shared library is
one that is dynamically loadable, which is what Python requires to
one that is dynamically loadable, which is what Python requires to
...
@@ -32,4 +34,40 @@ extra libraries must also be shared libraries. If the LAMMPS
...
@@ -32,4 +34,40 @@ extra libraries must also be shared libraries. If the LAMMPS
shared-library build fails with an error complaining about this, see
shared-library build fails with an error complaining about this, see
the "Build_basics"_Build_basics.html doc page.
the "Build_basics"_Build_basics.html doc page.
TODO: Also include CMake info on this
Build LAMMPS as a shared library using CMake :h4
When using CMake the following two options are necessary to generate the LAMMPS
shared library:
-D BUILD_LIB=on # enable building LAMMPS as a library
-D BUILD_SHARED_LIBS=on # enable building of LAMMPS shared library (both options are needed!) :pre
What this does is create a liblammps.so which contains the majority of LAMMPS
code. The generated lmp binary also dynamically links to this library. This
means that either this liblammps.so file has to be in the same directory, a system
library path (e.g. /usr/lib64/) or in the LD_LIBRARY_PATH.
If you want to use the shared library with Python the recommended way is to create a virtualenv and use it as
CMAKE_INSTALL_PREFIX.
# create virtualenv
virtualenv --python=$(which python3) myenv3
source myenv3/bin/activate :pre
# build library
mkdir build
cd build
cmake -D PKG_PYTHON=on -D BUILD_LIB=on -D BUILD_SHARED_LIBS=on -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV ../cmake
make -j 4 :pre
# install into prefix
make install :pre
This will also install the Python module into your virtualenv. Since virtualenv
doesn't change your LD_LIBRARY_PATH, you still need to add its lib64 folder to
it, which contains the installed liblammps.so.
export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib64:$LD_LIBRARY_PATH :pre
Starting Python outside (!) of your build directory, but with the virtualenv
enabled and with the LD_LIBRARY_PATH set gives you access to LAMMPS via Python.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment