-
Notifications
You must be signed in to change notification settings - Fork 228
FAQ: CMake Build Problems
Below are a list of common issues and errors related to the CMake build. See the install guide for instructions on how to build Macaulay2 using CMake. If you run into a problem not listed below or among the list of issues labeled with build system, please open a new issue.
Installing dependencies using Linuxbrew
On macOS CMake automatically finds libraries installed on the Homebrew prefix. In order to use Linuxbrew (which has the same interface and packages), use the following command to tell CMake to look under the right prefix:
cmake -DCMAKE_SYSTEM_PREFIX_PATH=`brew --prefix` .
/usr/include/c++/10.1.0/bits/unique_ptr.h:594:9: error: no matching function for call to std::__uniq_ptr_data
when using GCC 10 or Clang 10
This issue is due to an old version of FFLAS_FFPACK or Givaro libraries inserting an unnecessary -fabi-version=6
flag to the compile command. Use the following command to tell CMake to build those libraries:
cmake -DBUILD_LIBRARIES="Givaro;FFLAS_FFPACK" .
/usr/include/boost/regex/v4/cpp_regex_traits.hpp:966: undefined reference to `boost::re_detail_107100::cpp_regex_traits_implementation::transform_primary(char const*, char const*) const'
Same as above.
CMake is not using the local version of MPIR, Flint, etc.
Currently, when CMake is set to use the MPIR library, it compiles MPIR and a number of other libraries from source, including MPFR, NTL, Flint, Factory, Frobby, and Givaro. This is done to avoid linking conflicts caused by the libraries linking instead with the GMP library. Therefore, in order to link with system libraries the -DUSING_MPIR=OFF
option is required. See this comment for more details on the reasoning behind this.
No download info given for 'build-flint' and its source directory
When building from a downloaded archive (i.e., not a git repository), it is necessary to also download and extract archives of the required submodules in the M2/submodules
directory.
If a given library is not required on a particular system, CMake might still complain that the submodule directory is empty. One way to prevent this is to create a dummy file in the submodule directory for the libraries that are not required; for instance:
touch M2/submodules/flint2/empty
Detected library incompatibilities; rerun the build-libraries target
This message indicates that the build scripts detected an inconsistency between the libraries found on the system, and that those libraries are marked to be compiled from source. Run ninja build-libraries
(or make build-libraries
) to build the libraries from source.
If the problem persists, run cmake --debug-trycompile
and open an issue with the contents of CMakeFiles/CMakeError.log
.
macOS 10.15 Catalina issues with Clang and AppleClang
Clang: The Clang compiler installed via Homebrew or built from source typically includes OpenMP, but by default the system root is set to the Xcode SDK directory which does not contain the libomp.dylib
library. The following command tells Clang how to find the correct library path:
export LIBRARY_PATH=`llvm-config --libdir`
cmake -S../.. -B. -GNinja -DCMAKE_BUILD_TYPE=Release
The llvm-config
executable is typically located at /usr/local/opt/llvm/bin/llvm-config
.
AppleClang: After ensuring that you have followed the usual steps from the INSTALL manual (e.g. running xcode-select --install
, consider setting the CMAKE_OSX_SYSROOT
variable to match the current SDK:
cmake -DCMAKE_OSX_SYSROOT=`xcrun --show-sdk-path` .
This would, for instance, tell CMake to look in /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX.sdk/usr/include
for headers.
Moreover, when building with MPIR, adding the following option allows CMake to find OpenMP from its own prefix rather than the common prefix at /usr/local
, which may help avoid linking conflicts:
cmake -DCMAKE_SYSTEM_PREFIX_PATH=`brew --prefix libomp` .
If problems persist for either compiler, open an issue.
M2/include/M2/config.h:75:0: warning: "HAVE_ALARM" redefined
This error indicates that a previous in-source build has files left in the source tree. Run make clean distclean
from the source directory or start from a clean clone of Macaulay2.
engine.h:84:3: error: ‘gmp_arrayZZ’ does not name a type; did you mean ‘gmp_newZZ’?
Same as above.
gmp-util.h:96:31: error: ‘gmp_CCmutable’ was not declared in this scope
Same as above.
mpirxx.h:3482:13: error: ‘mpir_ui’ has not been declared
This error indicates that a system version of gmp.h
was found before mpir.h
. If this occurs, open an issue.
undefined reference to `GC_malloc`
This error occurs if the GC library path is not set correctly.
[ 4%] Linking C executable scc1 CMakeFiles/scc1.dir/scc1.c.o: In function `getmem': /home/macaulay/M2/M2/Macaulay2/c/scc1.c:23: undefined reference to `GC_malloc'
Use the following command to tell CMake to build BDWGC:
cmake -DBUILD_LIBRARIES=BDWGC .
error: Runtime CPU support is only available with GCC 4.6 or later.
When compiling using Clang, the following error might occur if NTL was built with GCC instead:
[ 25%] Building CXX object Macaulay2/e/CMakeFiles/M2-engine.dir/ntl-internal.cpp.o In file included from M2/Macaulay2/e/ntl-debugio.cpp:4: In file included from M2/Macaulay2/e/./ntl-interface.hpp:16: In file included from /usr/include/NTL/ZZ.h:18: In file included from /usr/include/NTL/lip.h:5: /usr/include/NTL/ctools.h:510:2: fatal error: Runtime CPU support is only available with GCC 4.6 or later. #error Runtime CPU support is only available with GCC 4.6 or later. ^
Use the following command to tell CMake to build NTL:
cmake -DBUILD_LIBRARIES=NTL .
Linking error when readline
installed in a non-standard location
When compiling with several versions of readline
installed (such as when using Gentoo Prefix), compilation may fail at the linking step
Linking CXX executable usr-dist/x86_64-Linux-RedHatEnterprise-7.9/bin/M2-binary FAILED: usr-dist/x86_64-Linux-RedHatEnterprise-7.9/bin/M2-binary : && ~/gentoo/usr/bin/c++ -O3 -DNDEBUG -march=native -g3 -L~/M2-test/usr-host/lib -fopenmp Macaulay2/system/CMakeFiles/M2-supervisor.dir/supervisor.cpp.o Macaulay2/system/CMakeFiles/M2-supervisor.dir/m2file.cpp.o Macaulay2/system/CMakeFiles/M2-supervisor.dir/tests.cpp.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/M2types.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/M2lib.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/M2mem.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/scclib.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/memdebug.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/debug.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/gmp_aux.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/gdbm_interface.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/arithmetic-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/atomic-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/M2-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/system-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/strings-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/varstrin-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/strings1-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/errio-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/vararray-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/ctype-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/nets-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/varnets-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/interrupts-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/pthread0-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/stdiop0-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/gmp-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/engine-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/xml-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/stdio0-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/parse-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/expr-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/stdio-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/stdiop-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/err-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/gmp1-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/tokens-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/getline-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/lex-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/parser-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/binding-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/basic-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/convertr-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/common-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/util-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/struct-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/classes-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/buckets-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/equality-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/hashtables-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/regex-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/sets-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/evaluate-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/mysqldummy-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/pthread-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors2-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors3-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors4-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/xmlactors-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors5-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/actors6-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/threads-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/interface-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/interface2-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/texmacs-tmp.c.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/interp-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/version-tmp.cc.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/boost-regex.cpp.o Macaulay2/d/CMakeFiles/M2-interpreter.dir/xml-c.c.o Macaulay2/bin/CMakeFiles/M2-binary.dir/timestamp.cpp.o Macaulay2/bin/CMakeFiles/M2-binary.dir/main.cpp.o Macaulay2/bin/CMakeFiles/M2-binary.dir/startup.c.o -o usr-dist/x86_64-Linux-RedHatEnterprise-7.9/bin/M2-binary -Wl,-rpath,/usr/lib64::::::::::::::::::::::::::::::: Macaulay2/e/libM2-engine.a -ldl -ldl -lpthread ~/gentoo/usr/lib64/libboost_regex.so.1.76.0 ~/gentoo/usr/lib64/libopenblas.so ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/libgfortran.so usr-host/lib/libgivaro.a usr-host/lib/libmps.a ~/gentoo/usr/lib64/libfrobby.so usr-host/lib/libfactory.a ~/gentoo/usr/lib64/libflint.so ~/gentoo/usr/lib64/libntl.so usr-host/lib/libmpfi.a ~/gentoo/usr/lib64/libmpfr.so ~/gentoo/usr/lib64/libgc.so ~/gentoo/usr/lib64/libgmpxx.so ~/gentoo/usr/lib64/libgmp.so ~/gentoo/usr/lib64/liblapack.so ~/gentoo/usr/lib64/libblas.so ~/gentoo/usr/lib64/libtbb.so ~/gentoo/usr/lib64/libxml2.so /usr/lib64/libreadline.so /usr/lib64/libhistory.so ~/gentoo/usr/lib64/libgdbm.so ~/gentoo/usr/lib64/libatomic_ops.so ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/libgomp.so ~/gentoo/usr/lib64/libpthread.so && cd ~/M2-test/Macaulay2/bin && ~/gentoo/usr/bin/cmake -E echo --\ Linked\ libraries: && LD_LIBRARY_PATH=~/M2-test/usr-host/lib: ~/gentoo/usr/bin/ldd ~/M2-test/usr-dist/x86_64-Linux-RedHatEnterprise-7.9/bin/M2-binary && ~/gentoo/usr/bin/cmake -E echo --\ INSTALL_RPATH:\ /usr/local/lib64/Macaulay2/lib ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE' ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE' ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE' ~/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
Use the CMake variable READLINE_ROOT_DIR
to tell CMake where to find the right version of readline
. The specified directory should contain the file include/readline/readline.h
. In the case of Gentoo Prefix, one should run:
cmake -DREADLINE_ROOT_DIR=$HOME/gentoo/usr .
collect2: error: ld returned 1 exit status
on WSL2
This issue is likely due to a memory exhaustion bug in WSL2. Try cleaning the build artifacts and building with parallelization disabled:
ninja clean
ninja M2-core -j1
sh: 1: Syntax error: "(" unexpected
See #1503.
undefined reference to cblas_dgemm
on Arch Linux
The default OpenBLAS package on Arch Linux does not include function declarations for LAPACK and CBLAS, causing issues with some libraries and parts of Macaulay2. Try installing the community package [OpenBLAS-LAPACK](https://aur.archlinux.org/packages/openblas-lapack/) instead.
How to compile with Intel(R) Math Kernel Library
MKL is a linear algebra routines library specifically optimized for Intel(R) processors. To enable linking with MKL, adjust the path and architecture appropriately and run the following before calling cmake
:
source /opt/intel/bin/compilervars.sh intel64
Note that MKL is closed-source but released as a freeware.
See FindLAPACK for information on specifying the linear algebra library by setting the value of BLA_VENDOR
in cmake/check-libraries.cmake
.
How to compile with AMD(R) Optimizing CPU Libraries
TODO: AOCL includes AMD BLIS and AMD libFLAME
Homepage | Projects | Packages | Documentation | Events | Google Group