Getting the SoftwareThe
libMeshsource can be downloaded from our GitHub release page. Stable releases are located there as compressed tar archives. You may also access the Git source tree for the latest code. You can get read-only access to the Git repository via:
git clone git://github.com/libMesh/libmesh.git
If you would like to contribute to the project you will need a GitHub developer account, or you can contribute patches. To create a patch from a modified Git tree simply do:
git diff > patch
in the top-level directory. You can then submit the file
libMeshmakes extensive use of the standard C++ library and increasing use of C++11 standard language and library features, so you will need a recent, standards-compliant compiler. We have tried very hard to make the code compiler-agnostic by avoiding questionable constructs. If you have a C++11-supporting compiler that won't build libMesh code please let us know. You will also need a decent C compiler if you want to build some of the contributed packages that add functionality to the library.
libMeshContinuous Integration testing of all library modifications currently is done with gcc 6.2 and gcc 7.3. Less frequent testing is done with clang, Intel, and older gcc compilers.
libMeshhas many features which are enabled via integration with various third-party libraries, a few of which are redistributed in our contrib directory, others of which may be separately installed on your system. The libMesh configure script attempts to autodetect these libraries when possible. Some of the supported libraries have occasionally changing (or even frequently changing) APIs. We attempt to provide a range of backwards compatibility for old versions of third-party APIs.
ConfigurationConfiguring the library is straightforward. The GNU autoconf package is used to determine site-specific configuration parameters. A standard build will occur after typing
in the top-level project directory. To see all the configuration options type
The configure script will find your compilers and create
Makefiles with the configuration specific for your site. If you want to use different compilers than those found by configure you can specify them in environment variables. For example, the following will build with the macports
Clangcompilers, and also specifies nonstandard search paths for a number of optional libraries:
./configure --prefix=/tmp/foo \ --with-glpk-include=/opt/local/include \ --with-glpk-lib=/opt/local/lib \ --with-vtk-include=/opt/local/include/vtk-5.10 \ --with-vtk-lib=/opt/local/lib/vtk-5.10 \ --with-eigen-include=/opt/local/include/eigen3 \ --with-cxx=clang++-mp-3.2 --with-cc=clang-mp-3.2 --disable-fortran
Note that the Fortran compiler is not actually used to compile any part of the library, but
configureuses it to find out how to link Fortran libraries with C++ code, and it is possible to compile
libMeshwithout a Fortran compiler.
Building the LibraryTo build the library you need
Makeand a supported compiler, as listed in the Compiler section. After the library is configured simply type
maketo build the library.
./configurescript distributed with the library looks at the shell environment variable
METHODSto determine what modes the library should be built in. Valid values for
dbg(build with debug symbols), and
pro(build with profiling support for use with
gprof). Once the library is configured you can build it simply by typing
Testing the Library
Running the Examples
libMeshincludes a number of examples in the
examplesdirectory. From the top-level directory you can build and run the example programs by typing
Note that many of the the example programs create output in the
ExodusIIformat, since you can download Paraview for free, and it is a highly capable postprocessing tool. It is a simple matter to change the source in the example to write a different formats, however.
Unit TestsThe source tree contains a
testsentry in the main trunk that contains a series of unit tests which can be used to validate a
libMeshinstallation. These unit tests require CPPUnit to run properly. To run the unit test suite, from the build directory, simply do
make -C tests check
Linking With Your ApplicationSince
libMeshcan be configured with many additional packages we recommend including the
Make.commonfile created in the top-level directory in the
Makefileof any application you want to use with the library. This will properly set the
libmesh_LIBSvariables, which you can append to with your own stuff.
For testing simple programs you may want to use the
libmesh-configscript included in the
contrib/bindirectory instead of creating a
Makefile. This script may be used to determine the relevant compilation and linking flags used by
libMesh. For example, you could build the application
`libmesh-config --cxx` -o foo foo.C `libmesh-config --cxxflags --include --ldflags --libs`
Building on Windows
After installing msys2 you need to install the mingw-w64 C++ compiler. To check that the installation was successfull, you can run
in the msys2 shell.
When you checkout the current version of
libMesh using Git on Windows
symlinks might not work. You can check whether your symlinks are set correctly by
inspecting whether the README file points to the README.md file. If this is not the
case, you should run the
contrib/bin/fix_windows_symlinks.sh from within
the git repository using the msys2 shell. This script removes all symlinks and copies
the symlink targets to the corresponding places.
Not all optional dependencies are available on Windows. It is known that the following packages do not compile on Windows.
- fparser, Function Parser for C++
- METIS, Serial Graph Partitioning and Fill-reducing Matrix Ordering
Hence, these libraries need to be deactivated, using the corresponding flags.
For example by configuring
libMesh with the following command.
./configure --prefix=c:/libmesh \ --disable-metis \ --with-fparser=none
Then, the library can be built and installed using:
make make install