CMake can not find g++ compiler on Windows

只愿长相守 提交于 2021-02-04 16:08:39

问题


I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows.

For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables:

CC = C:\MinGW\bin\gcc
CXX = C:\MinGW\bin\g++

But when I run CMake it does not detect any compilers and tells me:

-- The C compiler identification is unkown
-- The CXX compiler identification is unkown

I created a super basic example on github which I would like to get running on Windows + MinGw: https://github.com/j-o-d-o/Basic-CMake-Project

How can I use the env variables in windows to force CMake to use g++ and gcc compiler?


回答1:


I needed to add -G "MinGW Makefiles" to the CMake command.

I check if I am on Windows and if yes, I add the parameter to the CMake command in the shell script. I also need to use mingw32-make instead of make when I am on Windows.

There are some other issues now, but it resolves the issue/question I have posted.



来源:https://stackoverflow.com/questions/51979949/cmake-can-not-find-g-compiler-on-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!