c++ - VSCode C++ 编译错误:如何链接附加库 (*.lib)?
问题描述
我正在设置 VS Code 环境 (Windows) 来编译 Visual Studio C 项目。在源文件中调用了一个附加/外部 *.lib 文件。并且在如图所示的目录中。该项目在 Visual Studio 中运行良好。但是当我在 VS Code 中编译它时,编译器在附加的 *.lib 中找不到函数。
task.json 和 c_cpp_properties.json 如下。
任务.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”之后添加路径
推荐阅读
- r - 按 R 和 P 值对 ggscatter 着色
- firebase - Flutter:Flutter 应用中 Google Maps API 的 Firebase 实时更新
- transition - 使用 Tailwind 的 Vue 转换
- c++ - 解决矢量问题时捕获致命信号 11
- android - 如何使用 FlutterDriver 在 Flutter App 中测试原生 Android 方法?
- c# - 在c#中到达数组的末尾或开头时如何环绕索引?
- pyomo - Pyomo:如何定义与变量相关的参数
- python - 如何使用 Python pandas 从 csv 中仅读取某些行和单元格?
- python - 使用 Python 在 Windows 上使用 PyAudio 和 Sounddevice 时增加 RAM 使用率
- citrus-framework - 带有报告的柑橘性能负载测试