你如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11588855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for building Assimp for iOS?
提问by Curyous
When I try to build Assimp by running build_ios.sh
, it tells me:
当我尝试通过运行构建 Assimp 时build_ios.sh
,它告诉我:
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.
What I need the path to be is:
我需要的路径是:
/Applications/XCode.app/Contents/Developer/Platforms/...
I've tried changing DEVROOT
in build_ios.sh
and IPHONE_xxxx_TOOLCHAIN.cmake
, because that's what CMAKE_C_COMPILER
etc seem to get generated from, but it still gives me the same errors.
我试着改变DEVROOT
的build_ios.sh
和IPHONE_xxxx_TOOLCHAIN.cmake
,因为那是什么CMAKE_C_COMPILER
等似乎得到从产生,但它仍然给了我同样的错误。
回答by abi
Option 1:
选项1:
You can set CMake variables at command line like this:
您可以在命令行中设置 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
See thisto learn how to create a CMake cache entry.
请参阅此内容以了解如何创建 CMake 缓存条目。
Option 2:
选项 2:
In your shell script build_ios.sh
you can set environment variables CC
and CXX
to point to your C and C++ compiler executable respectively, example:
在您的 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
Option 3:
选项 3:
Edit the CMakeLists.txt file of "Assimp": Add these lines at the top (must be added before you use project()
or enable_language()
command)
编辑“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")
See thisto learn how to use set
command in CMake. Also thisis a useful resource for understanding use of some of the common CMake variables.
请参阅此内容以了解如何set
在 CMake 中使用命令。另外这是了解使用的一些常见的CMake变量的一个有用的资源。
Here is the relevant entry from the official FAQ: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
这是官方常见问题解答中的相关条目:https: //gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
回答by neoneye
The cc and cxx is located inside /Applications/Xcode.app
. This should find the right paths
cc 和 cxx 位于/Applications/Xcode.app
. 这应该找到正确的路径
export CXX=`xcrun -find c++`
export CC=`xcrun -find cc`