I'm trying to compile a .c
file that's an example from an API. That API also has a .lib
and a .h
. It's my first time using VS Code. My file structure is as follows:
I have been fighting with the compiler to be able to link the .lib
. Since, at the beginning, following this answer, the functions used were all "undefined reference".
As a result, I tried to follow this answer instead.
My tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "Compiler",
"type": "shell",
"command": "g++",
"args": [
"-c",
"${workspaceFolder}\\example.c",
"-IC:\\myproj"
]
},
{
"label": "Linker",
"type": "shell",
"command": "g++",
"args": [
"${workspaceFolder}\\example.o",
"-o",
"${workspaceFolder}\\bin\\example.exe",
"-LC:\\myproj",
"-lmingw32",
"-lSDL2main",
"-lSDL2"
]
},
{
"label": "Build Example",
"dependsOn": [
"Compiler",
"Linker"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
And my c_cpp_properties.json
:
{
"configurations": [
{
"name": "Win32",
"browse": {
"path": [
"C:\\myproj","${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"C:\\myproj","${workspaceFolder}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
After trying to build (Shift
+Ctrl
+B
), I get this:
Starting build...
C:\MinGW\bin\gcc.exe -fdiagnostics-color=always -g C:\myproj\example.c -o C:\myproj\example.exe
spawn C:\WINDOWS\system32\cmd.exe ENOENTBuild finished with error(s).
What should I do?