当我尝试通过运行 build_ios.sh
构建 Assimp 时,它告诉我:
CMake Error: your C compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
我需要的路径是:
/Applications/XCode.app/Contents/Developer/Platforms/...
我已经尝试更改 build_ios.sh
和 IPHONE_xxxx_TOOLCHAIN.cmake
中的 DEVROOT
,因为这就是 CMAKE_C_COMPILER
etc 似乎是从中生成的,但它仍然给我同样的错误。
最佳答案
选项 1:
您可以像这样在命令行设置 CMake 变量:
cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable" /path/to/directory/containing/CMakeLists.txt
参见 this了解如何创建 CMake 缓存条目。
选项 2:
在您的 shell 脚本 build_ios.sh
中,您可以设置环境变量 CC
和 CXX
分别指向您的 C 和 C++ 编译器可执行文件,示例:
export CC=/path/to/your/c/compiler/executable
export CXX=/path/to/your/cpp/compiler/executable
cmake /path/to/directory/containing/CMakeLists.txt
选项 3:
编辑“Assimp”的 CMakeLists.txt 文件:在顶部添加这些行(必须在使用 project()
或 enable_language()
命令之前添加)
set(CMAKE_C_COMPILER "/path/to/your/c/compiler/executable")
set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable")
参见 this学习如何在 CMake 中使用 set
命令。还有 this是了解一些常见 CMake 变量的使用的有用资源。
这是来自官方常见问题解答的相关条目:https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
关于ios - 如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11588855/