首页 > 酒水资讯 > 酒水功效

c语言visual studio下载,visualstudio创建c语言文件

酒易淘 酒水功效 2022-09-03 12:17:42

品牌名称:酱香白酒加盟 所属行业:酒水 > 白酒

基本投资:10~50万元 投资热度:

加盟意向:1634 门店数量:534家

索要资料 查看详情

  

  最近根据项目需求,需要搭建在鳏夫下使用visual studio 2022集成开发环境工具远程在Linux操作系统操作系统平台c环境。网上查了很多资料,可供参考的资料特别少,经过多轮配置,现将配置的基本步骤分享给大家。   

  

  要求如下:   

  

  1、c 11标准   

  

  2、编译工具第一种   

  

  3、编译器(同地面控制中心)地面控制中心   

  

  4、包管理工具Vcpkg(微软C团队开发的适用于C和C库的跨平台开源软件包管理器)   

  

  5、jsoncpp(一款基于c的数据三方处理库)   

  

  一、卡姆克安装   

  

  1、下载网址:https://cmake。组织/下载/   

  

  2、版本:Cmake 3.23.1   

  

  3、安装步骤   

  

  tar-zvxf cmake-3.23.1.tar.gz CD cmake-3。23 .1/。/bootstrap make制造安装如出现如下提示:请安装openssl-devel   

  

  找不到OpenSSL .安装心脏出血开发包或   

  

  将CMake配置为-DCMAKE_USE_OPENSSL=OFF,以便在不使用心脏出血的情况下进行构建。   

  

  RM-f cmake缓存。txt yum-y install ncurses-devel yum install OpenSSL-devel二、Linux下vcpkg安装   

  

  1、下载网址:https://github。com/Microsoft/VC pkg   

  

  2、安装步骤   

  

  饭桶克隆https://github.com/microsoft/vcpkgcd。/bootstrap-vcpkg.sh 3、设置环境变量   

  

  VI/etc/profile导出路径=$ PATH :/root/VC pkg/source/etc/profile三、vcpkg下jsoncpp安装   

  

  vcpkg集成安装vcpkg安装jsoncpp:x64-linux生成的提示信息,很重要,cmakeLists一定要按照如下配置   

  

  jsoncpp提供了CMake目标:   

  

  #这是启发式生成的,可能不正确   

  

  查找包(需要jsoncpp配置)target _ link _ libraries(主私有JSON CPP _ object JSON CPP _ static JSON CPP : JSON CPP)   

  

  这段代码加入cmakeLists.txt   

  

  四、vs2022配置   

  

  1、配置vs2022远程跨平台链接   

  

  工具-选项-跨平台-添加SSH linux服务器链接   

  

     

  

  2、新建工程   

  

  选择,Cmake项目(生成不依赖于。豆状下核或。项目文件支持的跨平台C应用)   

  

  3、cmakeLists.txt配置   

  

  # CMakeList.txt:视频的CMake项目,在此处包括源代码并定义# 项目特定的逻辑。1 # CMAKE _ minimum _ REQUIRED(3。23 .一版)项目(' video ')set(CMAKE _ CXX _ STANDARD 11)set(SOURCES ' src/')find _ package(需要jsoncpp配置)#用于创建可执行文件,第一个参数是可执行文件名字,第二个参数为需要用到的源文件add _ executable(video ' $ { SOURCES } main。CPP ' ' $ { SOURCES } header/main。h ' ' $ { SOURCES }操作视频。CPP ' ' $ { SOURCES }头/操作视频。h ' ' $ { SOURCES }标题/操作JSON。h ' ' $ { SOURCES } oper JSON。CPP ')#用于指明构建目标的依赖库,第一个参数为构建目标,第三个参数为依赖库目标_链接_库(视频私有JSON CPP _ object JSON CPP _ static JSON CPP : JSON CPP)4、CmakeSettings.json配置文件如下   

  

{"configurations": <{"name": "x64-Debug","generator": "Ninja","configurationType": "Debug","inheritEnvironments": < "msvc_x64_x64" >,"buildRoot": "${projectDir}\\out\\build\\${name}","installRoot": "${projectDir}\\out\\install\\${name}","cmakeCommandArgs": "","buildCommandArgs": "","ctestCommandArgs": ""},{"addressSanitizerEnabled": false,"buildCommandArgs": "","cmakeCommandArgs": "","cmakeExecutable": "cmake","cmakeToolchain": "/root/vcpkg/scripts/buildsystems/vcpkg.cmake","configurationType": "Debug","ctestCommandArgs": "","generator": "Unix Makefiles","inheritEnvironments": < "linux_x64" >,"intelliSenseMode": "linux-gcc-x64","name": "Linux-GCC-Debug","remoteBuildRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/out/build/${name}","remoteCMakeListsRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/src","remoteCopyAdditionalIncludeDirectories": < "/usr/local/lib/", "usr/local/include/", "/root/vcpkg/installed/x64-linux/include" >,"remoteCopyBuildOutput": true,"remoteCopySources": true,"remoteCopySourcesExclusionList": < ".vs", ".git", "out" >,"remoteCopySourcesMethod": "rsync","remoteInstallRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/out/install/${name}","remoteMachineName": "-1539221974;192.168.2.188 (username=root, port=22, authentication=Password)","rsyncCommandArgs": "-t --delete --delete-excluded","variables": <{"name": "_VCPKG_INSTALLED_DIR","value": "/root/vcpkg/installed","type": "PATH"},{"name": "VCPKG_APPLOCAL_DEPS","value": "true","type": "BOOL"}>},{"name": "Linux-GCC-Release","generator": "Unix Makefiles","configurationType": "RelWithDebInfo","cmakeExecutable": "cmake","remoteCopySourcesExclusionList": < ".vs", ".git", "out" >,"cmakeCommandArgs": "","buildCommandArgs": "","ctestCommandArgs": "","inheritEnvironments": < "linux_x64" >,"remoteMachineName": "${defaultRemoteMachineName}","remoteCMakeListsRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/src","remoteBuildRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/out/build/${name}","remoteInstallRoot": "$HOME/vs/${projectDirName}/${workspaceHash}/out/install/${name}","remoteCopySources": true,"rsyncCommandArgs": "-t --delete --delete-excluded","remoteCopyBuildOutput": false,"remoteCopySourcesMethod": "rsync"},{"name": "WSL-GCC-Debug","generator": "Unix Makefiles","configurationType": "Debug","buildRoot": "${projectDir}\\out\\build\\${name}","installRoot": "${projectDir}\\out\\install\\${name}","cmakeExecutable": "cmake","cmakeCommandArgs": "","buildCommandArgs": "","ctestCommandArgs": "","inheritEnvironments": < "linux_x64" >,"wslPath": "${defaultWSLPath}"}>}5、新建main.cpp

  

#include "json/json.h"#include <iostream>#include <memory>/*** \brief Parse a raw string into Value object using the CharReaderBuilder* class, or the legacy Reader class.* Example Usage:* $g++ readFromString.cpp -ljsoncpp -std=c++11 -o readFromString* $./readFromString* colin* 20*/int main() {const std::string rawJson = R"({"Age": 20, "Name": "colin"})";const auto rawJsonLength = static_cast<int>(rawJson.length());constexpr bool shouldUseOldWay = false;JSONCPP_STRING err;Json::Value root;if (shouldUseOldWay) {Json::Reader reader;reader.parse(rawJson, root);} else {Json::CharReaderBuilder builder;const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());if (!reader->parse(rawJson.c_str(), rawJson.c_str() + rawJsonLength, &root,&err)) {std::cout << "error" << std::endl;return EXIT_FAILURE;}}const std::string name = root<"Name">.asString();const int age = root<"Age">.asInt();std::cout << name << std::endl;std::cout << age << std::endl;return EXIT_SUCCESS;}以上就是vs2022远程linux下开发环境配置,亲测可以用。

免费咨询
免费获取加盟资料