我正在尝试在Mac M1上构建CMake
$ arch
arm64
clang
version is
$ clang --version
Apple clang version 14.0.0 (clang-1400.0.29.201)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
clang++
version is
$ clang++ --version
Apple clang version 14.0.0 (clang-1400.0.29.201)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
CMake源:https://github.com/Kitware/CMake.git,分支:master
要引导,我运行命令:
$ export CC=clang
$ export CXX=clang++
$ ./configure --prefix=/usr/local/cmake/3.25.1
这会导致错误:
---------------------------------------------
CMake 3.25.1, Copyright 2000-2022 Kitware, Inc. and Contributors
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: cmake-3.25.1/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
日志中显示的错误是:
ld: unknown option: --rpath=/path/to/opt/anacounda3/lib:-L/path/to/opt/anaconda3/lib:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Test failed to compile
我试着:
clang -Wl,-rpath,/path/to/opt/anacounda3/lib:-L/path/to/opt/anaconda3/lib: -framework CoreFoundation
这会产生错误:
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我的PATH
包含:
/Library/Developer/CommandLineTools/usr/bin:/usr/bin:
我可以做些什么来解决这个问题?
我的bash源环境变量LDFLAGS=/path/to/opt/anacounda3/lib:-L/path/to/opt/anaconda3/lib:
。把这个注释掉可以修复这个问题。