[英]How Do I Set Include Path Library Directory And Linker For VSCODE When I Have Visual C++ Build Tools To Work With (not g++)
我已將 VS 代碼設置為我的開發環境,並使用MSVC
構建工具( cl.exe
編譯器)而不是g++
。 我嘗試為我的環境設置SFML
。 我想知道如何設置SFML
包含路徑和庫路徑。 而且,我如何執行 static 與cl.exe
的鏈接。 注意:我只使用 VS 代碼而不是 Visual Studio 進行編程。 以下是我使用過的一些文件。 Tasks.json
, Launch.json
, C_cpp_properties.json
。
任務.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe:",
"${workspaceFolder}\\bin\\${fileBasenameNoExtension}.exe",
"${workspaceFolder}\\*.cpp"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
發射.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "cl.exe - Build and debug active file",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\bin\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"preLaunchTask": "C/C++: cl.exe build active file"
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
如評論中所述,您需要使用 C++ 構建系統來管理依賴項並構建您的項目。 VSCode 沒有像 Visual Studio 這樣的內置構建系統。
VSCode 任務允許您指定命令行,然后可以在 IDE 中輕松調用該命令行。 顯示的任務只是一個“構建活動文件”任務,它只對沒有依賴關系的瑣碎程序真正有用。 它在當前源文件上調用cl.exe
(並傳遞一些其他參數)。
您可以通過添加到任務中的“args”數組來指定包含目錄並將 arguments 傳遞給 linker,例如:
"/I", "D:\\Code Libraries\\boost_1_77_0",
"/link", "/LIBPATH:\"D:\\Code Libraries\\boost_1_77_0\\stage\\lib\"",
它假定 boost 頭文件和(靜態構建的)庫位於指定位置。
您可能可以通過添加帶有 VSCode 任務的命令行來了解如何構建整個項目,但使用構建系統可能更容易(即使該系統是 CMake)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.