cmake 更改编译器VsCode

dced5bon  于 2023-01-26  发布在  Vscode
关注(0)|答案(2)|浏览(215)

我是c++新手cmakelist.txt文件没有给予我Makefile

-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The C compiler identification is MSVC 19.29.30140.0
-- The CXX compiler identification is MSVC 19.29.30140.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/JohnSmith/Documents/Hello/build

我不知道如何将编译器更改为G++这是cmake

cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
project(HelLo)
add_executable(Hello main.cpp hello.cpp)

我在windows上,谢谢帮助(我可以用g++和gcc编译,只是cmakefile不起作用)

s2j5cfk0

s2j5cfk01#

cmake -G“Unix生成文件”..

2ul0zpep

2ul0zpep2#

首先,确保你已经安装了gcc/g++ under Windows(CygWin或MinGW),从你的CMakelists.txt中删除set命令,然后在CygWin/MinGW shell中使用以下命令生成Makefile:

CC=gcc CXX=c++ cmake ..

相关问题