Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

VS Code always gives includePath errors for custom headers. How do I fix it?

$
0
0

In my attempt to make the program, I always run into includePath errors in my VS Code. I can only import standard libraries like stdio.h, stdlib.h and such header files only. In case I try to import a custom header file, say gtk-3.0, I run into includePath errors. Even for files that were installed with msys2 like openssl. I need your help to learn more and fix this issue. So that despite using any header file (in-built or external) without running into includePath error squiggles in VS Code forever.

Here is what I have done:

I am trying to build a simple project with gtk-3.0 which validates phone numbers. My setup is Windows 11 with Visual Studio Code. I have installed C development environment using MSYS2 from here: https://www.msys2.org. After installing MSYS2, I ran the following commands in the MSYS utility -

pacman -Syupacman -Supacman -S mingw-w64-x86_64-gtk3 mingw-w64-x86_64-glib2 mingw-w64-x86_64-cairo mingw-w64-x86_64-pango mingw-w64-x86_64-gdk-pixbuf2

After this was done, I added the following to both user and system environment variables:

D:\ProgramFiles\msys64D:\ProgramFiles\msys64\ucrt64\binD:\ProgramFiles\msys64\ucrt64D:\ProgramFiles\msys64\ucrt64\includeD:\ProgramFiles\msys64\mingw64D:\ProgramFiles\msys64\mingw64\include

In my VS Code, I have configured c_cpp_properties.json like this:

{"configurations": [    {"name": "Win32","includePath": ["${workspaceFolder}/**","D:/ProgramFiles/msys64/mingw64/include","D:/ProgramFiles/msys64/mingw64/include/gtk-3.0","D:/ProgramFiles/msys64/mingw64/include/glib-2.0","D:/ProgramFiles/msys64/ucrt64/include","D:/ProgramFiles/msys64/mingw64/include/pango"      ],"defines": [],"compilerPath": "D:\\ProgramFiles\\msys64\\ucrt64\\bin\\gcc.exe","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "windows-gcc-x64","browse": {"path": ["D:/ProgramFiles/msys64/mingw64/include","D:/ProgramFiles/msys64/mingw64/include/gtk-3.0","D:/ProgramFiles/msys64/mingw64/include/glib-2.0","D:/ProgramFiles/msys64/ucrt64/include","D:/ProgramFiles/msys64/mingw64/include/pango"        ],"limitSymbolsToIncludedHeaders": true,"databaseFilename": ""      }    }  ],"version": 4}

Everytime I try importing external headers, like #include <gtk-3.0/gtk/gtk.h> the line is squiggled and I get this error on hover:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (E:\Projects\C\phval.c).C/C++(1696)cannot open source file "pango/pango.h" (dependency of "C:\Users\adars\.vscode\extensions\ms-vscode.cpptools-1.20.5-win32-x64\bin\gtk-3.0\gtk\gtk.h")C/C++(1696)

And another error:

E:\Projects\C>cd "e:\Projects\C\" && gcc phval.c -o phval && "e:\Projects\C\"phvalphval.c:1:29: fatal error: gtk-3.0/gtk/gtk.h: No such file or directory #include <gtk-3.0/gtk/gtk.h>                             ^compilation terminated.

This happens despite explicitly adding gtk-3.0 to includePath in the cpp configuration. Please help me fix this. I don't understand why it is unable to find pango.h as I have explicity added D:/ProgramFiles/msys64/mingw64/include/pango and it contains the said file. Thus, this being the reason, I would like to find a way so I can just include a path after which I don't have to specifically mention includePaths to pango.h or other million dependencies.

This might be a novice question, but I would really appreciate solutions.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>