Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ VSCode C++;编译错误:如何链接其他库(*.lib)?_C++_Visual Studio Code_Compiler Errors_Mingw - Fatal编程技术网

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

C++ VSCode C++;编译错误:如何链接其他库(*.lib)?,c++,visual-studio-code,compiler-errors,mingw,C++,Visual Studio Code,Compiler Errors,Mingw,我正在设置VS代码环境(Windows)来编译VisualStudioC项目。源文件中调用了一个附加的/external*.lib文件。该项目在VisualStudio中运行良好。但是当我在VS代码中编译它时,编译器在附加的*.lib中找不到函数 task.json和c_cpp_properties.json如下所示 task.json { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentati

我正在设置VS代码环境(Windows)来编译VisualStudioC项目。源文件中调用了一个附加的/external*.lib文件。该项目在VisualStudio中运行良好。但是当我在VS代码中编译它时,编译器在附加的*.lib中找不到函数

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代码环境中链接*.lib吗?

您好,我知道这可能太晚了, 但我只是偶然发现了这个,
尝试将路径添加到“-o

是否使用
#pragma comment
功能?看起来您添加了目录以查找库,但没有添加库。我认为在Visual Studio中,您依赖的是
#pragma comment
。我认为
mingw
不支持这一点。谢谢您的回复<代码>#pragma comment不起作用。您找到解决此问题的方法了吗?