我在尝试使用 Emscripten 构建项目时遇到了一个持续存在的问题。尽管尝试了各种常见的解决方案,但我仍无法解决该错误。通过 emmake make 使用 CMake 时,在配置步骤中会出现该问题。这是我看到的输出和错误消息:
shell
Copy code
make: make
[ 0%] Performing configure step for 'glm_project'
-- The CXX compiler identification is Clang 19.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /Users/someuser/emsdk/upstream/emscripten/em++
-- Check for working CXX compiler: /Users/someuser/emsdk/upstream/emscripten/em++ - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.30.2/share/cmake/Modules/CMakeTestCXXCompiler.cmake:73 (message):
The C++ compiler
"/Users/someuser/emsdk/upstream/emscripten/em++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/Users/someuser/supertux/build/glm_project-prefix/src/glm_project-build/CMakeFiles/CMakeScratch/TryCompile-pxq0PV'
Run Build Command(s): /opt/homebrew/Cellar/cmake/3.30.2/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_44f92/fast
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_44f92.dir/build.make CMakeFiles/cmTC_44f92.dir/build
Building CXX object CMakeFiles/cmTC_44f92.dir/testCXXCompiler.cxx.o
/Users/c_dominguez/emsdk/upstream/emscripten/em++ -sDISABLE_EXCEPTION_CATCHING=0 -fno-strict-aliasing -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -MD -MT CMakeFiles/cmTC_44f92.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_44f92.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_44f92.dir/testCXXCompiler.cxx.o -c /Users/someuser/supertux/build/glm_project-prefix/src/glm_project-build/CMakeFiles/CMakeScratch/TryCompile-pxq0PV/testCXXCompiler.cxx
em++: error: x86_64: No such file or directory ("x86_64" was expected to be an input file, based on the commandline arguments provided)
make[4]: *** [CMakeFiles/cmTC_44f92.dir/testCXXCompiler.cxx.o] Error 1
make[3]: *** [cmTC_44f92/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:15 (project)
-- Configuring incomplete, errors occurred!
make[2]: *** [glm_project-prefix/src/glm_project-stamp/glm_project-configure] Error 1
make[1]: *** [CMakeFiles/glm_project.dir/all] Error 2
make: *** [all] Error 2
emmake: error: 'make' failed (returned 2)
我尝试过的:
检查环境变量中特定于 macOS 的选项:
环境清理:
已验证是否无意中包含任何 macOS SDK 路径或选项。取消设置潜在冲突的环境变量。
重新安装工具链:
详细的 CMake 输出:
以详细模式运行 CMake 以跟踪导致失败的确切命令,从而认识到
-arch x86_64
标志导致了问题。
上下文:
观察:
该错误似乎源于 Emscripten 将
-arch x86_64
解释为输入文件而不是编译标志。
该项目似乎正在选取 macOS 特定的构建标志,这些标志与 Emscripten 不兼容。
请求帮助: 有没有人有类似问题的经验?如何防止 Emscripten 选择这些不兼容的标志?是否有我可能忽略的其他环境或 CMake 配置?