MacOS Ventura 13.4.1安装Ipopt遇clang不支持-fopenmp错误求助
在MacOS Ventura 13.4.1编译Ipopt时遇到
-fopenmp不支持错误 我在MacOS Ventura 13.4.1系统中安装Ipopt时陷入编译错误。按照官方安装文档指引执行./configure后,运行make命令进行编译,出现如下错误:
... CXXLD libipopt.la clang: error: unsupported option '-fopenmp' make[3]: *** [libipopt.la] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all] Error 2 make: *** [all-recursive] Error 1
我已经通过以下命令安装了llvm和libomp:
brew install llvm brew install libomp
但问题仍未解决,希望得到帮助。
以下是完整的configure命令输出:
checking build system type... aarch64-apple-darwin22.5.0 checking host system type... aarch64-apple-darwin22.5.0 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a race-free mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether to enable maintainer-specific portions of Makefiles... no checking whether make supports the include directive... yes (GNU style) checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... none needed checking whether gcc understands -c and -o together... yes checking dependency style of gcc... gcc3 checking for g++... g++ checking whether the compiler supports GNU C++... yes checking whether g++ accepts -g... yes checking for g++ option to enable C++11 features... none needed checking dependency style of g++... gcc3 checking whether g++ understands -c and -o together... yes checking for gfortran... gfortran checking whether the compiler supports GNU Fortran 77... yes checking whether gfortran accepts -g... yes checking how to get verbose linking output from gfortran... -v checking for Fortran 77 libraries of gfortran... -L/opt/homebrew/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/13 -L/opt/homebrew/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/13/../../.. -lgfortran -lemutls_w -lquadmath checking for dummy main to link with Fortran 77 libraries... none checking for Fortran 77 name-mangling scheme... lower case, underscore, no extra underscore checking whether gfortran understands -c and -o together... yes checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 786432 checking how to convert aarch64-apple-darwin22.5.0 file names to aarch64-apple-darwin22.5.0 format... func_convert_file_noop checking how to convert aarch64-apple-darwin22.5.0 file names to toolchain format... func_convert_file_noop checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for file... file checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s checking for ar... ar checking for archiver @FILE support... no checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /bin/dd checking how to truncate binary pipes... /bin/dd bs=4096 count=1 checking for mt... no checking if : is a manifest tool... no checking for dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking the archiver (ar) interface... ar checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.5.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common -DPIC checking if g++ PIC flag -fno-common -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.5.0 dyld checking how to hardcode library paths into programs... immediate checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for gfortran option to produce PIC... -fno-common checking if gfortran PIC flag -fno-common works... yes checking if gfortran static flag -static works... no checking if gfortran supports -c -o file.o... yes checking if gfortran supports -c -o file.o... (cached) yes checking whether the gfortran linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.5.0 dyld checking how to hardcode library paths into programs... immediate configure: libtool version info: -version-number 3:14:13 configure: Assuming that CXXLIBS is -lc++. configure: configuring doxygen documentation options checking for doxygen... no checking for latex... no checking for dot... NO checking for library containing cos... none required checking for pkgconf... no checking for pkg-config... pkg-config checking pkg-config is at least version 0.16.0... yes: 0.29.2 configure: pkg-config path is "/usr/local/lib/pkgconfig:" checking for LAPACK... yes: Accelerate framework (-framework Accelerate) checking for package ASL... yes checking for package Mumps... yes checking for MPI_Initialized... no checking for package HSL... yes checking for function ma27ad_ in -L/usr/local/lib -lcoinhsl ... yes checking for function ma28ad_ in -L/usr/local/lib -lcoinhsl ... yes checking for function pardiso_ in -framework Accelerate ... no checking for function pardiso in -framework Accelerate ... no checking for function PARDISO_ in -framework Accelerate ... no checking for function PARDISO in -framework Accelerate ... no checking for function pardiso__ in -framework Accelerate ... no checking for function pardiso_ in -framework Accelerate ... no checking for function PARDISO__ in -framework Accelerate ... no checking for function PARDISO_ in -framework Accelerate ... no checking for library Spral with combined link and compile check... skipping (default) checking size of int *... 8 checking for cmath... yes checking for cfloat... yes checking for cieeefp... no checking for ieeefp.h... no checking for g++ options needed to detect all undeclared functions... none needed checking for std::isfinite... yes checking whether va_copy is declared... yes checking for vsnprintf... yes checking whether drand48 is declared... yes checking whether rand is declared... yes checking for std::srand... yes checking whether feenableexcept is declared... no checking for gcj... no checking for guavac... no checking for jikes... no checking for javac... javac checking if javac works... yes checking if javac supports -h... yes checking for javac... /usr/bin/javac checking jni headers... /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/include checking for jar... jar checking for kaffe... no checking for java... java checking for javadoc... javadoc checking whether the linear solver loader should be used... yes checking for dlopen in -ldl... yes checking for windows.h... no checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating src/ipopt.pc config.status: creating src/Makefile config.status: creating src/Apps/AmplSolver/Makefile config.status: creating src/Apps/AmplSolver/ipoptamplinterface.pc config.status: creating test/Makefile config.status: creating test/run_unitTests config.status: creating doc/Doxyfile config.status: creating examples/Cpp_example/Makefile config.status: creating examples/recursive_nlp/Makefile config.status: creating examples/hs071_cpp/Makefile config.status: creating examples/hs071_c/Makefile config.status: creating examples/ScalableProblems/Makefile config.status: creating tutorial/CodingExercise/C/1-skeleton/Makefile config.status: creating tutorial/CodingExercise/C/2-mistake/Makefile config.status: creating tutorial/CodingExercise/C/3-solution/Makefile config.status: creating tutorial/CodingExercise/Cpp/1-skeleton/Makefile config.status: creating tutorial/CodingExercise/Cpp/2-mistake/Makefile config.status: creating tutorial/CodingExercise/Cpp/3-solution/Makefile config.status: creating tutorial/CodingExercise/Matlab/1-skeleton/startup.m config.status: creating tutorial/CodingExercise/Matlab/2-mistake/startup.m config.status: creating tutorial/CodingExercise/Matlab/3-solution/startup.m config.status: creating examples/hs071_f/Makefile config.status: creating examples/hs071_f/hs071_f.f config.status: creating tutorial/CodingExercise/Fortran/1-skeleton/TutorialFortran.f config.status: creating tutorial/CodingExercise/Fortran/2-mistake/TutorialFortran.f config.status: creating tutorial/CodingExercise/Fortran/3-solution/TutorialFortran.f config.status: creating tutorial/CodingExercise/Fortran/1-skeleton/Makefile config.status: creating tutorial/CodingExercise/Fortran/2-mistake/Makefile config.status: creating tutorial/CodingExercise/Fortran/3-solution/Makefile config.status: creating examples/hs071_java/Makefile config.status: creating examples/ScalableProblems_java/Makefile config.status: creating contrib/sIPOPT/Makefile config.status: creating contrib/sIPOPT/src/Makefile config.status: creating contrib/sIPOPT/AmplSolver/Makefile config.status: creating contrib/sIPOPT/examples/parametric_cpp/Makefile config.status: creating contrib/sIPOPT/examples/parametric_dsdp_cpp/Makefile config.status: creating contrib/sIPOPT/examples/redhess_cpp/Makefile config.status: creating contrib/RInterface/src/Makevars config.status: creating src/Common/config.h config.status: creating src/Common/config_ipopt.h config.status: linking examples/hs071_cpp/hs071_main.cpp to test/hs071_main.cpp config.status: linking examples/hs071_cpp/hs071_nlp.cpp to test/hs071_nlp.cpp config.status: linking examples/hs071_cpp/hs071_nlp.hpp to test/hs071_nlp.hpp config.status: linking examples/hs071_c/hs071_c.c to test/hs071_c.c config.status: linking contrib/sIPOPT/examples/parametric_cpp/parametric_driver.cpp to test/parametric_driver.cpp config.status: linking contrib/sIPOPT/examples/parametric_cpp/parametricTNLP.cpp to test/parametricTNLP.cpp config.status: linking contrib/sIPOPT/examples/redhess_cpp/MySensTNLP.cpp to test/MySensTNLP.cpp config.status: linking contrib/sIPOPT/examples/redhess_cpp/redhess_cpp.cpp to test/redhess_cpp.cpp config.status: executing depfiles commands config.status: executing libtool commands configure: Configuration of Ipopt successful
解决方案
问题根源是系统默认clang不支持-fopenmp选项,即便安装了libomp,也需要指定使用brew安装的llvm编译器来编译Ipopt,具体步骤如下:
- 清理之前configure生成的文件:
make distclean
- 临时将brew安装的llvm编译器加入当前终端环境变量:
export PATH="/opt/homebrew/opt/llvm/bin:$PATH" export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" export CC=clang export CXX=clang++
- 重新运行configure并启用OpenMP:
./configure --enable-openmp
- 执行编译和安装:
make make install
如果仍有问题,可以选择禁用OpenMP编译(放弃并行支持):
./configure --disable-openmp make make install
内容的提问来源于stack exchange,提问作者Axolotl
相关产品推荐
相关产品推荐

