Macaulay2 » Documentation
Packages » Macaulay2Doc » setting up Macaulay2 » teaching M2 how to find its shared libraries
next | previous | forward | backward | up | index | toc

# teaching M2 how to find its shared libraries

Perhaps you know that your M2 executable is located at /foo/bar/bin/M2, but when you run it, you get something like this:

    $ /foo/bar/bin/M2
    M2: error while loading shared libraries: liblapack.so: cannot open shared object file: No such file or directory

Or something like this:

    $ /foo/bar/bin/M2
    dyld: Library not loaded: libgmp.3.dylib
      Referenced from: /foo/bar/bin/M2
      Reason: image not found
    Trace/BPT trap

What that means is that M2 cannot locate its shared libraries. Hopefully, the missing shared libraries are located in /foo/bar/lib, and all we have to do is to tell the operating system by setting the environment variable LD_LIBRARY_PATH on Unix-based systems and DYLD_LIBRARY_PATH on MacOS-based systems.

If you have downloaded a version of Macaulay2 that comes with dynamically loaded libraries of its own, they will be in the directory /foo/bar/lib64/Macaulay2/lib.

    LD_LIBRARY_PATH=/foo/bar/lib64/Macaulay2/lib /foo/bar/bin/M2

After setting the environment variable temporarily, you can use setup to record the correct value in your system start up files.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_getting_started.m2:320:0.