2 years ago

#28365

test-img

Liam Monninger

How can I resolve glib.h not found clang compiler on Mac with VSCode?

I'm experimenting with using VSCode for C development on Mac. I've been having trouble getting VSCode to find glib.h. I installed glib with brew.

I've been using pkg-config to identify my path:

> pkg-config glib-2.0 --cflags
-I/opt/homebrew/Cellar/glib/2.70.2/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.70.2/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.45/include

And, have set my includePath accordingly:

"includePath": [
                "${workspaceFolder}/**",
                "/opt/homebrew/Cellar/glib/2.70.2/include/glib-2.0",
                "/opt/homebrew/Cellar/glib/2.70.2/lib/glib-2.0/include",
                "/opt/homebrew/opt/gettext/include",
                "/opt/homebrew/Cellar/pcre/8.45/include"
            ],

brew ls glib:

/opt/homebrew/Cellar/glib/2.70.2/bin/gdbus
/opt/homebrew/Cellar/glib/2.70.2/bin/gdbus-codegen
/opt/homebrew/Cellar/glib/2.70.2/bin/gio
/opt/homebrew/Cellar/glib/2.70.2/bin/gio-querymodules
/opt/homebrew/Cellar/glib/2.70.2/bin/glib-compile-resources
/opt/homebrew/Cellar/glib/2.70.2/bin/glib-compile-schemas
/opt/homebrew/Cellar/glib/2.70.2/bin/glib-genmarshal
/opt/homebrew/Cellar/glib/2.70.2/bin/glib-gettextize
/opt/homebrew/Cellar/glib/2.70.2/bin/glib-mkenums
/opt/homebrew/Cellar/glib/2.70.2/bin/gobject-query
/opt/homebrew/Cellar/glib/2.70.2/bin/gresource
/opt/homebrew/Cellar/glib/2.70.2/bin/gsettings
/opt/homebrew/Cellar/glib/2.70.2/bin/gtester
/opt/homebrew/Cellar/glib/2.70.2/bin/gtester-report
/opt/homebrew/Cellar/glib/2.70.2/etc/bash_completion.d/ (5 files)
/opt/homebrew/Cellar/glib/2.70.2/include/gio-unix-2.0/ (9 files)
/opt/homebrew/Cellar/glib/2.70.2/include/glib-2.0/ (262 files)
/opt/homebrew/Cellar/glib/2.70.2/lib/libgio-2.0.0.dylib
/opt/homebrew/Cellar/glib/2.70.2/lib/libglib-2.0.0.dylib
/opt/homebrew/Cellar/glib/2.70.2/lib/libgmodule-2.0.0.dylib
/opt/homebrew/Cellar/glib/2.70.2/lib/libgobject-2.0.0.dylib
/opt/homebrew/Cellar/glib/2.70.2/lib/libgthread-2.0.0.dylib
/opt/homebrew/Cellar/glib/2.70.2/lib/glib-2.0/include/glibconfig.h
/opt/homebrew/Cellar/glib/2.70.2/lib/pkgconfig/ (8 files)
/opt/homebrew/Cellar/glib/2.70.2/lib/ (10 other files)
/opt/homebrew/Cellar/glib/2.70.2/share/aclocal/ (3 files)
/opt/homebrew/Cellar/glib/2.70.2/share/bash-completion/ (5 files)
/opt/homebrew/Cellar/glib/2.70.2/share/gdb/ (2 files)
/opt/homebrew/Cellar/glib/2.70.2/share/gettext/ (2 files)
/opt/homebrew/Cellar/glib/2.70.2/share/glib-2.0/ (13 files)
/opt/homebrew/Cellar/glib/2.70.2/share/locale/ (98 files)

But, building from within VSCode results in:

fatal error: 'glib.h' file not found

c

visual-studio-code

clang

homebrew

glib

0 Answers

Your Answer

Accepted video resources