ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Cmake配置方法

Cmake配置方法 ubuntu上安装cmake从https://cmake.org/download/下载源码如cmake-3.24.1.tar.gz解压包tar-zxvfcmake-3.24.1.tar.gz进入到解压后的文件夹然后执行bootstrap文件进行检查cdcmake-3.24.1 ./bootstrap检查没有发现问题的话进行安装-j8是选择八核编译如果是电脑是四核就make -j4不清楚的就直接make影响不大只是编译速度的变化make-j8sudomakeinstall查看cmake版本 cmake --version查看cmake路径 which cmake如果成功输入版本信息则编译安装成功windows上安装cmake1、vscode安装拓展Cmake和Cmake Tools的拓展文件2、配置json文件//c_cpp_properties.json{configurations:[{name:Linux,includePath:[${workspaceFolder}/**], // 头文件路径defines:[],compilerPath:/usr/bin/gcc, // 编译器路径cStandard:c11, // c 标准cppStandard:c17, // c 标准intelliSenseMode:clang-x64,configurationProvider:ms-vscode.cmake-tools}],version:4}//launch.json{// Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // Formoreinformation, visit: https://go.microsoft.com/fwlink/?linkid830387version:0.2.0,configurations:[{name:(gdb) 启动,type:cppdbg,request:launch,program:${workspaceFolder}/build/application, //输入程序名称例如${workspaceFolder}/a.outargs:[test1,test2], //输入程序运行参数stopAtEntry:false,cwd:${workspaceFolder}/build, //设置程序运行初始路径environment:[],externalConsole:false,MIMode:gdb,setupCommands:[{description:为 gdb 启用整齐打印,text:-enable-pretty-printing,ignoreFailures:true}]}]}//tasks.json{// See https://go.microsoft.com/fwlink/?LinkId733558//forthe documentation about the tasks.jsonformatversion:2.0.0,tasks:[{label:make build,//编译的项目名buildtype:shell,command:cd ./build ;cmake ../ ;make,//编译命令group:{kind:build,isDefault:true}},{label:clean,type:shell,command:make clean,}]}3、ctrlshiftP 输入① “CmakeQuick start”②“项目名称”③“EXecutable”④点击底层的build⑤生成可执行文件Windows配置VScode的方法
返回列表