VSCode C ++编译错误:如何链接其他库(* .lib)?

时间:2019-06-22 12:52:45

标签: c++ visual-studio-code compiler-errors mingw

我正在设置VS Code环境(Windows)来编译Visual Studio C项目。在源文件中有一个附加的/外部* .lib文件。它在图中所示的目录中。该项目在Visual Studio中运行良好。但是,当我在VS Code中进行编译时,编译器无法在其他* .lib中找到函数。

project property of the Visual Studio C project

task.json和c_cpp_properties.json如下。

task.json

{
// See https://go.microsoft.com/fwlink/?LinkId=733558 
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "g++",
        "args": [
            "-g",
            "${file}",
            "-I",
            "C:/PROGRAM FILES (X86)/NATIONAL INSTRUMENTS/SHARED/EXTERNALCOMPILERSUPPORT/C/INCLUDE",
            "-L",
            "C:/PROGRAM FILES (X86)/NATIONAL INSTRUMENTS/SHARED/EXTERNALCOMPILERSUPPORT/C/LIB32/MSVC",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "C:\\mingw64\\bin"
        }
    }
]
}

c_cpp_properties.json

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}/**",
            "C:/PROGRAM FILES (X86)/NATIONAL INSTRUMENTS/SHARED/EXTERNALCOMPILERSUPPORT/C/INCLUDE"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "compilerPath": "C:\\mingw64\\bin\\g++.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "gcc-x64",
        "browse": {
            "path": [
                "${workspaceFolder}/**",
                "C:/PROGRAM FILES (X86)/NATIONAL INSTRUMENTS/SHARED/EXTERNALCOMPILERSUPPORT/C/INCLUDE"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        }
    }
],
"version": 4
}

是否可以像在Visual Studio中一样在VS Code环境中链接* .lib?

1 个答案:

答案 0 :(得分:0)

你好,我知道这太迟了, 但是我偶然发现了这个 尝试在“ -o

之后添加路径