我想編譯這個(相當複雜)一塊與cmake並MinGW的代碼在Windows中:cmake的問題
#include <iostream>
int main()
{
std::cout << "Test" << std::endl;
return 0;
}
這是CMakeLists.txt
文件(在Linux下正常工作):
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_C_COMPILER path/to/gcc)
SET(CMAKE_CXX_COMPILER path/to/g++)
project(cmake_test)
add_executable(a.exe test.cpp)
用命令:
cmake -G"MinGW Makefiles" .
我得到這些錯誤:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (MESSAGE):
sh.exe was found in your PATH, here:
C:/MinGW/msys/1.0/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
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: Could not find cmake module file:C:/cmake_test/CMakeFiles/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: Could not find cmake module file:C:/cmake_test/CMakeFiles/CMakeCXXCompiler.cmake
-- Configuring incomplete, errors occurred!
這些錯誤並沒有多大幫助。考慮到它在Linux中的作用,它必須與Window的配置有關。
謝謝你的幫助!
配置:
- Windows 7的
- 的MinGW/GCC 4.6.1
從C進行錯誤信息是明確的:確保你沒有在你的道路上。即:不要從MSys提示符運行CMake -G「MinGW Makefiles」。 –
那麼爲什麼在我的路徑中有sh.exe是一個問題? – odiszapc
通過運行'where sh.exe'我在'C:\ Cygwin64 \ bin \ sh.exe'和'C:\ Program Files \ OpenSSH'bin'sh.exe'找到它。我應該如何移除'Cygwin'和'OpenSSH'主文件夾而不破壞它們? – hyprfrcb