I am trying to figure out how to get gcc to recognize my GLFW include. intellisense currently says there aren't any issues. here is what my current code looks like in main.c:
#include <stdio.h>
#include <Include\glfw3.h>
int main()
{
printf("hello world");
getch();
}
And when I try to compile it:
PS D:\github\c> cd "d:\github\c\" ; if ($?) { gcc main.c -o main } ; if ($?) { .\main }
main.c:2:10: fatal error: glfw3.h: No such file or directory
2 | #include <glfw3.h>
| ^~~~~~~~~
compilation terminated.
I've tried editing c_cpp_properties.json, here's what it currently looks like:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}",
"${workspaceFolder}",
"${workspaceFolder}/**",
"D:\\github\\c\\Include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
And I couldn't get this to work, so I also tried editing tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"-I\"${workspaceFolder}/include**\"",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
this, also did not work.
And lastly I tried typing it manually, which did properly compile for no reason I can understand.
PS D:\github\c> gcc main.c -o main.exe -I"Include" -I"libs"
main.c: In function 'main':
main.c:7:5: warning: implicit declaration of function 'getch'; did you mean 'getc'? [-Wimplicit-function-declaration]
7 | getch();
| ^~~~~
| getc
edit: I just tried again and it no longer compiles when I type the command manually. what is happening??
I am kinda newbie too but i have a suggestion. Try:
#include "Include\glfw3.h"
instead of #include <Include\glfw3.h>
. I think that is how you import your own header files.