VS Code添加库依赖项?

时间:2017-07-15 15:57:57

标签: c++ dependencies visual-studio-code lib

我想将库依赖项添加到项目中,而不必将它们复制并粘贴到MinGW文件夹中。有没有办法通过VS Code来做到这一点?几乎与Visual Studio如何使用包含路径类似。

注意:我的配置会在您尝试添加外部依赖项之前进行编译并完美运行。

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceRoot}",
                "/usr/include",
                "/usr/local/include"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Linux",
            "includePath": [
                "${workspaceRoot}",
                "/usr/include",
                "/usr/local/include"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/include/*",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt",
                "${workspaceRoot}/Dep/include/*",
                "${workspaceRoot}/Dep/lib/glew32.lib"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/include/*",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ]
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "command": "g++",
    "type": "shell",
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared"
    },
    "tasks": [
      {
          "taskName": "Build",
          "suppressTaskName": true,
          "windows": {
                "args": [
                    "-g",
                    "--std=c++11",
                    "main.cpp",
                    "-o", "Builds/Win/engine",
                    "glew32.lib",
                    // LIB ARGS
                    "-lopengl32",
                    "-lglu32",
                    //"-lmingw32",
                    "-lglew32"
                ]
            }
        }  
    ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "request": "launch",
            "type": "cppvsdbg",
            "program": "${workspaceRoot}/Builds/Win/engine.exe",
            "preLaunchTask": "Build",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "windows": {
                "program": "${workspaceRoot}/Builds/Win/engine.exe"
            }
        }
    ]
}

0 个答案:

没有答案