VSCode C++ Compile Error: How to link an additional library (*.lib)?

Viewed 2926

I'm setting up the VS Code environment (Windows) to compile a Visual Studio C project. There is an additional/external *.lib file called in the source file. And it is in the directory shown in the figure. The project works well in Visual Studio. But when I compile it in VS Code, the compiler couldn't find the functions in the additional *.lib.

project property of the Visual Studio C project

The task.json and c_cpp_properties.json are as followed.

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
}

Can I link the *.lib in VS Code environment just like in Visual Studio?

1 Answers

hello i know this is probebly too late, but i just stumbled upon this, try adding the path after the "-o

Related