I'm currently trying to compile a C++ file using Visual Studio Code and I tried editing the c_cpp_properties.json
file adding the include folders in the includePath
variable and the tasks.json
file adding arguments but I still can't compile, it gives me this error:
LINK : fatal error LNK1104: can't open 'SDL2.lib'
Here are the files:
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\vclib\\include\\",
"C:\\vclib\\SDL2_image-2.0.5\\include\\"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"/IC:\\vclib\\include",
"/IC:\\vclib\\SDL2_image-2.0.5\\include",
"${file}",
"SDL2.lib", "SDL2main.lib", "SDL2_image.lib",
"/link /LIBPATH:C:\\vclib\\lib\\x64;C:\\vclib\\SDL2_image-2.0.5\\lib\\x64",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
UPDATE: the second file looks like this now:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"SDL2.lib", "SDL2main.lib","SDL2_image.lib",
"/IC:\\vclib\\include",
"/IC:\\vclib\\SDL2_image-2.0.5\\include",
"/link /LIBPATH:C:\\vclib\\lib\\x86", "/LIBPATH:C:\\vclib\\SDL2_image-2.0.5\\lib\\x86",
"/SUBSYSTEM:CONSOLE"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Now I have this error:
SDL2main.lib(SDL_windows_main.obj) : error LNK2019: extern symbol not resolved __imp__CommandLineToArgvW@8 referenced in function _main_getcmdline