我试图使用cmake构建一些我从github获得的代码,但不断收到以下错误:
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:/golang/project/src/github.com/devsisters/goquic/libquic/build/debug/CMakeFiles/2.8.11/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:/golang/project/src/github.com/devsisters/goquic/libquic/build/debug/CMakeFiles/2.8.11/CMakeCXXCompiler.cmake
-- Configuring incomplete, errors occurred!
有谁能告诉我如何正确设置这些变量?感谢。
使用github代码附带的./build_libs.sh文件来构建它。
答案 0 :(得分:12)
您正在执行的脚本使用cmake Ninja生成器。要做到这一点你需要忍者在路上。在大多数Linux发行版上,您可以从包中安装它。
Ubuntu:ninja-build
OpenSUSE:ninja
如果找不到它的发行版,则必须下载它并将其位置添加到路径环境变量中。
答案 1 :(得分:6)
我的解决方案:符号链接" ninja-build"到" ninja"。
# ln -s /usr/bin/ninja /usr/bin/ninja-build
这仅适用于非常旧版本的CMake,我将在下面解释。
我已经放弃了我的新鲜" ninja"二进制到/ usr / bin并检查它有0755权限。我被困住了,直到我对生成器命令进行了操作。
# strace cmake -GNinja .. | grep -i ninja
access("ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/texlive/2016/bin/i386-linux/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/root/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
它正在寻找" ninja-build",而不是" ninja"!
我在工作和家庭,Windows和Linux上广泛使用CMake和Ninja。那么为什么我以前没见过这个bug呢?
嗯......在这种情况下,我使用的是非常旧版本的CMake,版本2.8.12。它已经很老了,几乎已经化石了。所以推测它可能是后来修复的CMake错误,或者Ninja项目在某些时候更改了二进制文件的名称。
答案 2 :(得分:3)
如果$ PATH中确实存在ninja
但仍然无效,则应通过ls -l /PATH/TO/NINJA
检查可执行文件的权限。确保其他人已阅读&执行权限(如'-rwxr-xr-x')。
很抱歉发布新的答案而不是评论(我是新来的,没有足够的声誉)。
答案 3 :(得分:1)
你可能还会受苦
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
即使您已经拥有::
ninja
放在您的路径中ninja
具有适当权限的可执行文件那可能是因为同时指定了-D CMAKE_MAKE_PROGRAM
和-G Ninja
,但是CMAKE_MAKE_PROGRAM
的值无效(如空)。
带有 gradle 插件版本的 Android Studio :
classpath 'com.android.tools.build:gradle:7.0.0-alpha03'
并且不使用 SDK Manager 提供的 cmake,通过:
PATH
环境变量PATH
环境变量PATH
中指定与 build.gradle
中相同的 cmake 版本,例如: externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.19.1" // this line
}
}
然后实际上 gradle 像这样调用 cmake:
cmake ^
-HD:\dev\android_cv_examples\HelloNDK7\app\src\main\cpp ^
-DCMAKE_SYSTEM_NAME=Android ^
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON ^
-DCMAKE_SYSTEM_VERSION=26 ^
-DANDROID_ABI=arm64-v8a ^
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a ^
-DANDROID_NDK=D:\soft\Android\ndk-r21b ^
-DCMAKE_ANDROID_NDK=D:\soft\Android\ndk-r21b ^
-DCMAKE_TOOLCHAIN_FILE=D:\soft\Android\ndk-r21b\build\cmake\android.toolchain.cmake ^
-DCMAKE_MAKE_PROGRAM= ^
-DCMAKE_C_FLAGS= ^
-DCMAKE_CXX_FLAGS=-std=c++11 ^
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\dev\android_cv_examples\HelloNDK7\app\build\intermediates\cmake\debug\obj\arm64-v8a ^
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=D:\dev\android_cv_examples\HelloNDK7\app\build\intermediates\cmake\debug\obj\arm64-v8a ^
-DCMAKE_BUILD_TYPE=Debug ^
-BD:\dev\android_cv_examples\HelloNDK7\app\.cxx\cmake\debug\arm64-v8a ^
-GNinja ^
-DANDROID_PLATFORM=android-24
注意:如果删除以前的 cmake 构建缓存,并通过删除 -DCMAKE_MAKE_PROGRAM
修改该调用脚本,则问题将得到解决。