You are not logged in.

#1 2023-08-09 10:06:42

Red_S2
Member
Registered: 2023-02-04
Posts: 7

[SOLVED] gcc doesnt detect header files in /usr/include

gcc `pkg-config --cflags gtk4` main.c `pkg-config --libs gtk4`

returns gtk/gtk.h: No such file or directory

The files exists, the directories listed by pkg-config contain those headers, yet gcc, cc and clang cant find them.
If #include "/usr/include/gtk-4.0/gtk/gtk.h" is utilized it fails to detect the files required by gtk.h

Last edited by Red_S2 (2023-08-09 15:23:28)

Offline

#2 2023-08-09 10:45:05

solskogen
Member
From: Norway
Registered: 2005-03-06
Posts: 144

Re: [SOLVED] gcc doesnt detect header files in /usr/include

What does

pkg-config --cflags gtk4

return?

Offline

#3 2023-08-09 11:31:29

mpan
Member
Registered: 2012-08-01
Posts: 1,600
Website

Re: [SOLVED] gcc doesnt detect header files in /usr/include

I can’t reproduce this. In addition to what solskogen asked for, please provide the output of:

pacman -Q gtk4 gcc

and the simplest possible, minimal, valid⁽¹⁾ source code depicting the issue.

Note⁽²⁾ that “/usr/include” is special only to the includes, which are specified directly relative to it. Otherwise it is unimportant if the file is in some directory under “/usr/include” or elsewhere.
____
⁽¹⁾ That is: not your current source code.
⁽²⁾ The note included due to how the thread title is formed, suggesting a possible misconception about “/usr/include”.

Last edited by mpan (2023-08-09 11:32:25)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#4 2023-08-09 12:00:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: [SOLVED] gcc doesnt detect header files in /usr/include

Red_S2 wrote:

If #include "/usr/include/gtk-4.0/gtk/gtk.h" is utilized ...

Why would you use that line?  That makes pkg-conf irrelevant and makes the code not portable.  While this is not the cause of your current issue, the include line should be "#include <gtk/gtk.h>"


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2023-08-09 12:04:34

Red_S2
Member
Registered: 2023-02-04
Posts: 7

Re: [SOLVED] gcc doesnt detect header files in /usr/include

$ pkg-config --cflags gtk4
-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -mfpmath=sse -msse -msse2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/gio-unix-2.0 -I/usr/include/blkid -I/usr/include/pixman-1 -I/usr/include/libmount -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/sysprof-4 -pthread -I/usr/include/libpng16

Offline

#6 2023-08-09 12:07:58

Red_S2
Member
Registered: 2023-02-04
Posts: 7

Re: [SOLVED] gcc doesnt detect header files in /usr/include

current source code:

#include <gtk/gtk.h>

int
main (int argc, char **argv) {
  GtkApplication *app;
  int stat;

  app = gtk_application_new ("test", G_APPLICATION_DEFAULT_FLAGS);
  stat =g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);
  return stat;
}

Offline

#7 2023-08-09 12:30:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: [SOLVED] gcc doesnt detect header files in /usr/include

mpan wrote:

please provide the output of:

pacman -Q gtk4 gcc

I'd add the following:

pacman -Qkk gtk4

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2023-08-09 12:40:53

mpan
Member
Registered: 2012-08-01
Posts: 1,600
Website

Re: [SOLVED] gcc doesnt detect header files in /usr/include

Trilby: I believe they used the complete path include for testing purposes only.

Red_S2: There is a reason I was very precise with the source code request and even urged you to not post your current code. Please do not do this again, if you receive such a request. It serves a specific purpose.

In either case, I still can’t reproduce the issue. The code compiles and links just fine.

You did not post the output of `pacman -Q gtk4 gcc`. But, since you did not post it yet, please include Trilby’s request, and the output of one more command:

pacman -Q gtk4 gcc
pacman -Qkk gtk4
which gcc

Last edited by mpan (2023-08-09 12:42:43)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#9 2023-08-09 12:51:21

Red_S2
Member
Registered: 2023-02-04
Posts: 7

Re: [SOLVED] gcc doesnt detect header files in /usr/include

jef@Jacobs-PC ~> pacman -Qkk gtk4 gcc
gtk4: 823 total files, 0 altered files
gcc: 2649 total files, 0 altered files
jef@Jacobs-PC ~> which gcc
/usr/bin/gcc

couldnt post earlier because if been at school /w only my Laptop

Offline

#10 2023-08-09 13:34:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,116

Re: [SOLVED] gcc doesnt detect header files in /usr/include

What's your interactive shell?
What if you manually substitute the backtick-ridden `pkg-config --cflags gtk4`with the literal "-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -mfpmath=sse -msse -msse2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/gio-unix-2.0 -I/usr/include/blkid -I/usr/include/pixman-1 -I/usr/include/libmount -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/sysprof-4 -pthread -I/usr/include/libpng16" (w/o the quotes)?

Offline

#11 2023-08-09 15:08:12

loqs
Member
Registered: 2014-03-06
Posts: 18,931

Re: [SOLVED] gcc doesnt detect header files in /usr/include

If it is not the process substitution please post the output of the compile command with -v option added.

Offline

#12 2023-08-09 15:19:50

Red_S2
Member
Registered: 2023-02-04
Posts: 7

Re: [SOLVED] gcc doesnt detect header files in /usr/include

I am using the fish shell, for doing so i have to replace ` with brakets, I check that the out put is right before posting.

jef@Jacobs-PC ~/g/GTK_voc> echo (pkg-config --cflags --libs gtk4)
-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

gcc main.c -o app (pkg-config --cflags --libs gtk4) -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230801 (GCC)
COLLECT_GCC_OPTIONS='-o' 'app' '-I' '/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'app-'
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/cc1 -quiet -v -I /usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  main.c -quiet -dumpdir app- -dumpbase main.c -dumpbase-ext .c -mtune=generic -march=x86-64 -version -o /tmp/ccMVL5CO.s
GNU C17 (GCC) version 13.2.1 20230801 (x86_64-pc-linux-gnu)
    compiled by GNU C version 13.2.1 20230801, GMP version 6.3.0, MPFR version 4.2.0-p12, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 "
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include-fixed
/usr/include
End of search list.
Compiler executable checksum: 865c2688a4f1e3f13d6bf2cc8fd98762
main.c:1:10: fatal error: gtk/gtk.h: No such file or directory
    1 | #include <gtk/gtk.h>
      |          ^~~~~~~~~~~
compilation terminated.

Offline

#13 2023-08-09 15:22:24

Red_S2
Member
Registered: 2023-02-04
Posts: 7

Re: [SOLVED] gcc doesnt detect header files in /usr/include

It runs in bash, it was the shell

Offline

#14 2023-08-09 15:24:24

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,727

Re: [SOLVED] gcc doesnt detect header files in /usr/include

It seems to be passing the output as a single entity instead of splitting in on whitespace. This is a fish problem, I'd bet it works fine in bash.

Offline

Board footer

Powered by FluxBB