gpt4 book ai didi

c++ - VSCode C++编译错误: How to link an additional library (*.lib)?

转载 作者:行者123 更新时间:2023-12-01 14:58:47 27 4
gpt4 key购买 nike

我正在设置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?

最佳答案

你好,我知道这可能为时已晚,
但是我偶然发现了这个
尝试在“-o”后面添加路径

关于c++ - VSCode C++编译错误: How to link an additional library (*.lib)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56715651/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com