CMake/MinGW未知编译器,gcc.exe损坏 [英] CMake/MinGW unknown compilers, gcc.exe broken

查看:979
本文介绍了CMake/MinGW未知编译器,gcc.exe损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows桌面上安装一个名为NUPACK的软件套件,该套件用于设计核酸反应途径. http://www.nupack.org/

I am trying to install on my windows desktop, a software suite called NUPACK which is used to design nucleic acid reaction pathways. http://www.nupack.org/

此软件需要安装CMake,据我了解,CMake本身没有编译器,并且要求我们单独安装编译器.因此,我下载了MinGW用作C ++编译器.在运行之前,我已经设置了CMake和MinGW的bin的环境变量.我正在通过命令提示符运行CMake(版本3.11.1),但是我仍然遇到以下问题:

This software requires CMake to install, and from my understanding, CMake does not have compilers by itself, and requires us to have compilers separately installed. As such, I downloaded MinGW to use as a C++ compiler. Prior to running, I have set the environment variables of both CMake and MinGW's bin. I am running CMake (version 3.11.1) through the command prompt but I keep encountering the following problem:

C:\Users\Nicholas\Documents\nupack\build>Cmake -DCMAKE_INSTALL_PREFIX=NUPACKINSTALL -G "MinGW Makefiles" ..
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake- 
3.11/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "C:/MinGW/bin/gcc.exe"

  is not able to compile a simple test program.

我猜测CMake无法以某种方式识别我的MinGW gcc和gcc ++编译器.接下来,我尝试了以下操作,但是出现了相同的错误.

I'm guessing CMake cannot identify my MinGW gcc and gcc++ compilers somehow. I tried the following next, but the same error arose.

set CMAKE_C_COMPILER=%C:\mingw\bin\gcc%
set CMAKE_CXX_COMPILER=%C:\mingw\bin\g++%

有人遇到过同样的问题吗?可以使用MinGW64解决吗?我正在使用Windows 10,以前曾尝试使用Visual Studio 2017的编译器,但它也存在一系列问题.

Has anyone encountered the same problem? Can this be resolved by using MinGW64? I am using Windows 10 and previously, I tried using visual studio 2017's compilers, but it had its on set of problems too.

推荐答案

是的,问题在于CMake无法找到GCC编译器.在确保已安装g ++和gcc之前.可以是MinGW64或Cygwin.

Yes, the problem is that CMake cannot find GCC compiler. Before be sure that g++ and gcc are installed. It can be MinGW64 or Cygwin.

至少有三种方法可以链接GCC编译器.

There are at least three ways to link GCC compiler.

第一种方式:

CMakeLists.txt中设置编译器:

set(CMAKE_C_COMPILER C:\path\to\gcc.exe)
set(CMAKE_CXX_COMPILER C:\path\to\g++.exe)

第二种方式:

在终端或cmd中调用cmake时:

When calling cmake in terminal or cmd:

cmake -DCMAKE_C_COMPILER="C:\path\to\gcc.exe" -DCMAKE_CXX_COMPILER="C:\path\to\g++.exe"

第三种方式:

设置为环境变量: 转到Windows环境变量"并将其添加到PATH:

Set as environment variable: Go to Windows "Environment Variables" and add to PATH this:

;C:\path_to_MinGW_or_Cygwin\bin

这篇关于CMake/MinGW未知编译器,gcc.exe损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆