簡體   English   中英

如何在 Cygwin 中更改 C++ 編譯器?

[英]How to change the C++ compiler in Cygwin?

我用的是windows,需要編譯一個cpp文件。 我正在使用 Cygwin 運行命令sh 我已經安裝了 MinGw。 問題是當我運行命令時,我發現 Cygwin 正在調用 MinGw 的編譯器。 這是我得到的錯誤的痕跡:

 $ sh build_cpp.sh
mkdir: cannot create directory ‘build’: File exists
-- The CXX compiler identification is GNU 7.2.0
-- Check for working CXX compiler: /cygdrive/c/MinGW-124/MinGW-CPTR-124/bin/g++.exe
-- Check for working CXX compiler: /cygdrive/c/MinGW-124/MinGW-CPTR-124/bin/g++.exe -- broken
CMake Error at /usr/share/cmake-3.14.5/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "/cygdrive/c/MinGW-124/MinGW-CPTR-124/bin/g++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make.exe cmTC_71c00/fast
    /usr/bin/make -f CMakeFiles/cmTC_71c00.dir/build.make CMakeFiles/cmTC_71c00.dir/build
    make[1]: Entering directory '/cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_71c00.dir/testCXXCompiler.cxx.o
    /cygdrive/c/MinGW-124/MinGW-CPTR-124/bin/g++.exe     -o CMakeFiles/cmTC_71c00.dir/testCXXCompiler.cxx.o -c /cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    g++.exe: error: /cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx: No such file or directory
    g++.exe: fatal error: no input files
    compilation terminated.
    make[1]: *** [CMakeFiles/cmTC_71c00.dir/build.make:66: CMakeFiles/cmTC_71c00.dir/testCXXCompiler.cxx.o] Error 1
    make[1]: Leaving directory '/cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_71c00/fast] Error 2




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)


-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/users/user/PycharmProjects/crnn-master/src/cpp/build/CMakeFiles/CMakeError.log".
make: *** No targets specified and no makefile found.  Stop.
cp: cannot stat '*.so': No such file or directory

我嘗試更改環境變量,安裝 devel package 並使用命令cmake -d更改緩存變量(CMAKE_CXX_COMPILER,CMAKE_CC_COMPILER)。 我在哪里可以更改 Cygwin 的編譯器以便它使用它的編譯器?

我可能是由於您的 Windows 路徑變量。 如果您有多個名為 g++ 的二進制文件,其中一個來自 mingw,則應將正確的一個添加到您的環境變量中並刪除其他的。 還可以使用命令which g++來了解將使用哪個二進制文件。 您也可以提供正確編譯器的完整路徑作為解決方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM