【VS code】Remote编译及Debug配置

EXTENSIONS安装

用到的扩展工具包括C++,CMake tools,remote-SSH等;

配置文件

需要在代码路径下创建.vscode文件夹,放以下文件

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/include/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

cmake-variants.json

{
    "buildType": {
      "default": "debug",
      "description": "The build type.",
      "choices": {
        "debug": {
          "short": "Debug",
          "long": "Disable optimizations - include debug information.",
          "buildType": "Debug",
          "settings":{
            "Poco_ROOT_DIR":"../poco/build/android-arm64-31-Debug/install",
            "OPENSSL_ROOT_DIR":"../openssl/build/android-arm64-31-Debug/install",
            "SQLITE3_ROOT_DIR":"../sqlite/build/android-arm64-31-Release/install",
            "GTEST_ROOT_DIR":"../googletest/build/android-arm64-31-Debug/install",
            "CMAKE_FIND_ROOT_PATH":["../poco/build/android-arm64-31-Debug/install",
            "../openssl/build/android-arm64-31-Debug/install",
            "../sqlite/build/android-arm64-31-Release/install",
            "../googletest/build/android-arm64-31-Debug/install"]
          }
        },
        "release": {
          "short": "Release",
          "long": "Optimize for speed - exclude debug information.",
          "buildType": "Release",
          "settings": {
            "CMAKE_CXX_FLAGS_RELEASE":"-Wall -Os",
            "Poco_ROOT_DIR":"../poco/build/android-arm64-31-Release/install",
            "OPENSSL_ROOT_DIR":"../openssl/build/android-arm64-31-Release/install",
            "SQLITE3_ROOT_DIR":"../sqlite/build/android-arm64-31-Release/install",
            "GTEST_ROOT_DIR":"../googletest/build/android-arm64-31-Release/install",
            "CMAKE_FIND_ROOT_PATH":["../poco/build/android-arm64-31-Release/install",
            "../openssl/build/android-arm64-31-Release/install",
            "../sqlite/build/android-arm64-31-Release/install",
            "../googletest/build/android-arm64-31-Release/install"]
          }
        }
      }
    },
    "buildTarget": {
      "default": "x64",
      "description": "abi for 64 bit target build",
      "choices": {
        "local": {
          "short": "local",
          "long": "abi for linux x64 bit",
          "env": {
            "target":"local"
          },
          "settings": {
            "CMAKE_SYSTEM_NAME": "Linux",
            "CMAKE_INSTALL_PREFIX": "/usr/local",
            "CMAKE_CXX_COMPILER":"/usr/bin/g++",
            "CMAKE_C_COMPILER":"/usr/bin/gcc"
          }
        },
        "vs8": {
          "short": "vs8",
          "long": "vs8 plantform",
          "env": {
            "target":"vs8"
          },
          "settings": {
            "CMAKE_TOOLCHAIN_FILE": "../android-ndk-r25c/build/cmake/android.toolchain.cmake",
            "CMAKE_INSTALL_PREFIX":"install",
            "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM":"NEVER",
            "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY":"ONLY",
            "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE":"ONLY",
            "PLANTFORM":"Alios"
          }
        },
        "alios_x64": {
          "short": "alios_x64",
          "long": "alios_x64 plantform",
          "env": {
            "target":"x64"
          },
          "settings": {
            "CMAKE_SYSTEM_NAME": "Linux",
            "CMAKE_TOOLCHAIN_FILE": "../android-ndk-r25c/build/cmake/android.toolchain.cmake",
            "PLANTFORM":"Alios",
            "Project_Tests":"On"
          }
        },
        "android-arm64-31": {
          "short": "android-arm64-31",
          "long": "android arm64-v8a API-31 bit target build",
          "env": {
            "target":"android-arm64-31"
          },
          "settings": {
            "CMAKE_INSTALL_PREFIX": "install",
            "CMAKE_TOOLCHAIN_FILE": "../android-ndk-r25c/build/cmake/android.toolchain.cmake",
            "CMAKE_SYSTEM_NAME": "Android",
            "CMAKE_ANDROID_ARCH_ABI": "arm64-v8a",
            "BUILD_SHARED_LIBS":1,
            "LOCAL_LIBS":"--lfoo",
            "LOCAL_SHARED_LIBRARIES" : "log-lib",
            "ANDROID_ABI": "arm64-v8a",
            "ANDROID_NDK": "../android-ndk-r25c",
            "ANDROID_PLATFORM": "android-31",
            "CMAKE_SYSTEM_VERSION": 31,
            "ANDROID_STL":"c++_static",
            "APP_STL":"c++_static",
            "Project_Tests":"ON",
            "PLANTFORM":"Android"
          }
        },
        "android-x86_64-31": {
          "short": "android-x86_64-31",
          "long": "android x86_64 API-31 bit target build",
          "env": {
            "target":"android-x86_64-31"
          },
          "settings": {
            "CMAKE_INSTALL_PREFIX": "install",
            "CMAKE_TOOLCHAIN_FILE": "../android-ndk-r25c/build/cmake/android.toolchain.cmake",
            "CMAKE_SYSTEM_NAME": "Android",
            "CMAKE_ANDROID_ARCH_ABI": "x86_64",
            "BUILD_SHARED_LIBS":1,
            "LOCAL_LIBS":"--lfoo",
            "LOCAL_SHARED_LIBRARIES" : "log-lib",
            "ANDROID_ABI": "x86_64",
            "ANDROID_NDK": "../android-ndk-r25c",
            "ANDROID_PLATFORM": "android-31",
            "CMAKE_SYSTEM_VERSION": 31,
            "ANDROID": "ON",
            "ANDROID_STL":"c++_static",
            "Project_Tests":"OFF"
          }
        }
      }
    }
  }

settings.json

{
    "makefile.extensionOutputFolder": "./.vscode",
    "cmake.sourceDirectory": "../mosi-viwi/viwi_car_service_org",
    "cmake.buildDirectory": "${workspaceFolder}/build/${env.target}-${buildType}",
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true,
        "**/build*":true,
        "example":true
    },
    "files.associations": {
        "array": "cpp",
        "atomic": "cpp",
        "*.tcc": "cpp",
        "cctype": "cpp",
        "chrono": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "condition_variable": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "list": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "fstream": "cpp",
        "functional": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "memory": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "optional": "cpp",
        "ostream": "cpp",
        "ratio": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "thread": "cpp",
        "type_traits": "cpp",
        "tuple": "cpp",
        "typeinfo": "cpp",
        "utility": "cpp",
        "__config": "cpp",
        "cstdarg": "cpp",
        "cstring": "cpp",
        "algorithm": "cpp",
        "iomanip": "cpp",
        "numeric": "cpp",
        "cinttypes": "cpp",
        "__bit_reference": "cpp",
        "__debug": "cpp",
        "__errc": "cpp",
        "__functional_base": "cpp",
        "__hash_table": "cpp",
        "__locale": "cpp",
        "__mutex_base": "cpp",
        "__node_handle": "cpp",
        "__nullptr": "cpp",
        "__split_buffer": "cpp",
        "__string": "cpp",
        "__threading_support": "cpp",
        "__tree": "cpp",
        "__tuple": "cpp",
        "bit": "cpp",
        "bitset": "cpp",
        "cstddef": "cpp",
        "ios": "cpp",
        "iterator": "cpp",
        "locale": "cpp",
        "map": "cpp",
        "set": "cpp",
        "string": "cpp",
        "csignal": "cpp"
    }
}

demo.code-workspace

{
	"folders": [
		{
			"name":"CommonAPI_Java",
			"path": ".."
		},
		{
			"name":"CommonAPI_C++",
			"path": "../demo/src/main/cpp"
		}
	],
	"settings": {
		"java.configuration.updateBuildConfiguration": "automatic",
		"java.debug.settings.onBuildFailureProceed": true,
		"java.configuration.maven.globalSettings": "",
		"files.associations": {
			"iostream": "cpp",
			"e01helloworld.hpp": "c",
			"e01helloworldproxy.hpp": "c",
			"e01helloworldproxybase.hpp": "c",
			"e01helloworldstubdefault.hpp": "c",
			"helloworld.h": "c",
			"array": "cpp",
			"atomic": "cpp",
			"*.tcc": "cpp",
			"cctype": "cpp",
			"chrono": "cpp",
			"clocale": "cpp",
			"cmath": "cpp",
			"condition_variable": "cpp",
			"cstdarg": "cpp",
			"cstddef": "cpp",
			"cstdint": "cpp",
			"cstdio": "cpp",
			"cstdlib": "cpp",
			"cstring": "cpp",
			"ctime": "cpp",
			"cwchar": "cpp",
			"cwctype": "cpp",
			"deque": "cpp",
			"list": "cpp",
			"unordered_map": "cpp",
			"unordered_set": "cpp",
			"vector": "cpp",
			"exception": "cpp",
			"algorithm": "cpp",
			"functional": "cpp",
			"optional": "cpp",
			"ratio": "cpp",
			"string_view": "cpp",
			"system_error": "cpp",
			"tuple": "cpp",
			"type_traits": "cpp",
			"fstream": "cpp",
			"future": "cpp",
			"initializer_list": "cpp",
			"iomanip": "cpp",
			"iosfwd": "cpp",
			"istream": "cpp",
			"limits": "cpp",
			"memory": "cpp",
			"mutex": "cpp",
			"new": "cpp",
			"ostream": "cpp",
			"numeric": "cpp",
			"sstream": "cpp",
			"stdexcept": "cpp",
			"streambuf": "cpp",
			"thread": "cpp",
			"cinttypes": "cpp",
			"utility": "cpp",
			"typeinfo": "cpp",
			"iterator": "cpp",
			"map": "cpp",
			"memory_resource": "cpp",
			"random": "cpp",
			"set": "cpp",
			"string": "cpp",
			"base1.h": "c",
			"derived.h": "c",
			"e01helloworldproxy.h": "c",
			"e01helloworldproxybase.h": "c",
			"types.hpp": "c",
			"version.hpp": "c",
			"callinfo.hpp": "c",
			"export.hpp": "c",
			"commonapi.hpp": "c",
			"address.hpp": "c",
			"proxy.hpp": "c",
			"runtime.hpp": "c",
			"attribute.hpp": "c",
			"codecvt": "cpp",
			"any": "cpp",
			"locale": "cpp"
		}
	}
}

配置文件中,对应的project路径需要手动配置;其中,前三个文件是必须的,用于配置与执行Cmake的,最后一个.code-workspace是用于创建workspace的,可放在其它自建目录下,方便打开对应的工程的;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值