1,mingw64
下载mingwin64和sys
解压 -> 添加系统环境变量
../mingw64/bin/mingw32-make.exe -> 拷贝改名 make.exe
2,安装cmake
https://cmake.org/download/,安装 -> 添加系统环境变量
3,代码
3.1 main.c
#include<stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
3.2 CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(main)
set(CMAKE_CXX_STANDARD 11)
# 配置c/c++编译器
#SET(CMAKE_C_COMPILER "C:\\Program Files\\mingw64\\bin\\gcc.exe")
#SET(CMAKE_CXX_COMPILER "C:\\Program Files\\mingw64\\bin\\g++.exe")
add_executable(main main.c)
4,编译和运行
mkdir build && cd build
cmake -G "Unix Makefiles" ..
#cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..
main.exe
Hello World!
5,配置makefile
pytorch c++ 环境搭建