2012-10-24 8 views
9

Ich versuche, dieses (recht komplex) Stück Code mit cmake und MinGW unter Windows zu kompilieren:Cmake Probleme in Windows

#include <iostream> 

int main() 
{ 
    std::cout << "Test" << std::endl; 
    return 0; 
} 

Dies ist die CMakeLists.txt-Datei (die korrekt in Linux funktioniert):

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) 

Mit dem Befehl:

cmake -G"MinGW Makefiles" . 

Ich bekomme folgende Fehler:

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! 

Diese Fehler haben mir nicht viel geholfen. Wenn man bedenkt, dass es unter Linux funktioniert, muss es etwas mit der Konfiguration des Fensters zu tun haben.

Vielen Dank für jede Hilfe!

Konfiguration:
- Windows 7
- MinGW/GCC 4.6.1

+2

Die Fehlermeldung von CMake ist klar: Stellen Sie sicher, dass Sie nicht haben in deinem Weg. Das heißt: Führen Sie CMake -G "MinGW Makefiles" nicht in Ihrer MSys-Eingabeaufforderung aus. –

+0

Warum ist sh.exe in meinem Pfad ein Problem? – odiszapc

+0

Durch Ausführen von 'where sh.exe' fand ich es unter' C: \ Cygwin64 \ bin \ sh.exe' und 'C: \ Programme \ OpenSSH'bin'sh.exe'. Wie sollte ich 'Cygwin' und' OpenSSH' Hauptordner entfernen, ohne sie zu beschädigen? – hyprfrcb

Antwort

3

Dies ist auf die Sie in Ihrem Pfad haben C:/MinGW/msys/1.0/bin/, für Projekte mit CMake und MinGW zu erzeugen, ist es aus dem Weg löschen und fügen Sie C:/MinGW/bin/ statt

+0

Was ist 'C: \ ProgramData \ chocolatey \ lib \ msys2'. Ist das völlig unabhängig? – hyprfrcb

2

aus der PATH verbessert Sache Entfernen sh.exe.
ich mehr Fehler, aber zu einem späteren Zeitpunkt ...

5

können Sie bessere Ergebnisse mit -G "MSYS Makefiles" statt "MinGW Makefiles" - aber ich warne Sie - it is going to be slow.