[英]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.