You are not logged in.

#1 2014-03-13 18:23:08

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

[SOLVED] No such file or directory #include <gtk/gtk.h>

Hello,

gcc base.c -o base `pkg-config --cflags --libs gtk+-3.0`

gives error "fatal error: gtk/gtk.h: No such file or directory
#include <gtk/gtk.h>"

Best Regards,
Rasjid

Last edited by chanrasjid (2014-03-13 22:37:01)

Offline

#2 2014-03-13 18:26:17

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Do you have gtk3 installed?

What is the output of `pacman -Ql gtk3`?

Do you have a /usr/include/gtk-3.0/gtk/gtk.h file?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2014-03-13 18:43:50

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Hello,

Trilby wrote:

Do you have gtk3 installed?

What is the output of `pacman -Ql gtk3`?

Do you have a /usr/include/gtk-3.0/gtk/gtk.h file?

The ouptut is huge: 
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellArea.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellAreaBox.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellAreaContext.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellEditable.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellLayout.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRenderer.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererAccel.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererCombo.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererPixbuf.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererProgress.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererSpin.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererSpinner.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererText.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellRendererToggle.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCellView.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCheckButton.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkCheckMenuItem.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkColorButton.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkColorChooser.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkColorChooserDialog.html
gtk3 /usr/share/gtk-doc/html/gtk3/GtkColorChooserWidget.ht
...
...

The file '/usr/include/gtk-3.0/gtk/gtk.h' exist.

I compiled in my local home directory '/home/rasjid'

Best Regards,
Chan Rasjid.

Offline

#4 2014-03-13 18:59:38

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Then your compilation command should work.  Can you post the output of `pkg-config --cflags --libs gtk+-3.0`

Also, can you post the actual source file you are trying to compile?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2014-03-13 19:02:56

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

That's strange... This really should work.

Please post all of the source code that you are trying to compile. (But put it inside [ code ] tags so it's easy to read.) smile

What is the output of "pkg-config --cflags --libs gtk+-3.0"?

EDIT: Lol @ Trilby. ARE YOU ME?? big_smile

Last edited by drcouzelis (2014-03-13 19:03:39)

Offline

#6 2014-03-13 19:31:09

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Hello,

Trilby wrote:

Then your compilation command should work.  Can you post the output of `pkg-config --cflags --libs gtk+-3.0`

Also, can you post the actual source file you are trying to compile?

Hello,

Thanks, problem solved. (How do I mark this post solved?)

'pkg-config' was not installed for me; I don't remember there was any GTK+ development package mentioned.

So now 'gcc base.c -o base `pkg-config --libs --cflags gtk+-2.0` works.
But 3.0 does not work, has error:
`pkg-config --libs --cflags gtk+-3.0` - but that's a different problem.

base.c (example from official gnome gtk tutorial site):

#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *label;

    gtk_init(&argc, &argv);

    /* Create the main, top level window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    /* Give it the title */
    gtk_window_set_title(GTK_WINDOW(window), "Hello, world!");

    /*
    ** Map the destroy signal of the window to gtk_main_quit;
    ** When the window is about to be destroyed, we get a notification and
    ** stop the main GTK+ loop by returning 0
    */
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    /*
    ** Assign the variable "label" to a new GTK label,
    ** with the text "Hello, world!"
    */
    label = gtk_label_new("Hello, world!");

    /* Plot the label onto the main window */
    gtk_container_add(GTK_CONTAINER(window), label);

    /* Make sure that everything, window and label, are visible */
    gtk_widget_show_all(window);

    /*
    ** Start the main loop, and do nothing (block) until
    ** the application is closed
    */
    gtk_main();

    return 0;
}

Best Regards,
Rasjid

Offline

#7 2014-03-13 19:52:11

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

chanrasjid wrote:

Thanks, problem solved. (How do I mark this post solved?)

Glad that helped.  If you know how to track down the remaining 3.0 issue and consider this solved, you can click "edit" at the bottom right of your first post.  This will allow you to edit the title too and prepend the word [SOLVED] to the title.

drcouzelis wrote:

@ Trilby. ARE YOU ME?? big_smile

Not quite.  I have to flap my wings to fly.  I haven't mastered that hovering trick yet!

Last edited by Trilby (2014-03-13 19:53:25)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2014-03-13 20:02:20

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Just for future reference, always use code tags when posting any terminal output or code snippets:

Not using code tags is the leading cause for people's excommunication from houses of worship world-wide

All the best,

-HG

Offline

#9 2014-03-13 20:09:09

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Trilby wrote:
chanrasjid wrote:

Thanks, problem solved. (How do I mark this post solved?)

Glad that helped.  If you know how to track down the remaining 3.0 issue and consider this solved, you can click "edit" at the bottom right of your first post.  This will allow you to edit the title too and prepend the word [SOLVED] to the title.

drcouzelis wrote:

@ Trilby. ARE YOU ME?? big_smile

Not quite.  I have to flap my wings to fly.  I haven't mastered that hovering trick yet!

$ gcc main.c gui.c board.c -export-dynamic `pkg-config --cflags --libs gtk+-3.0` -o gui

error:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libgdk-3.so: undefined reference to `wl_proxy_marshal_constructor'
collect2: error: ld returned 1 exit status

Google search does not give anything relevant. The sources were working quite some times back. But I messed up my archlinux and re-installed everything from scratch. So, somehow, I cannot get a final working 'gui' executable now.

Best Regards,
Rasjid

Offline

#10 2014-03-13 20:46:14

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

No, really. Use code tags.

All the best,

-HG

Offline

#11 2014-03-13 21:13:39

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Well this is a completely different problem.  This is a linker error as you are using wayland functions but have not passed the relevant libs to the linker.

You'll probably be much better off using a Makefile and separating the compiling and the linking - this would make it even more clear at which step the error was.

If you post a link to the actual code we'll be able to actually figure out what is wrong.

You most likely need -lwayland-client for the LDLIBS.

Last edited by Trilby (2014-03-13 21:17:37)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#12 2014-03-13 22:34:10

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Trilby wrote:

Well this is a completely different problem.  This is a linker error as you are using wayland functions but have not passed the relevant libs to the linker.

You'll probably be much better off using a Makefile and separating the compiling and the linking - this would make it even more clear at which step the error was.

If you post a link to the actual code we'll be able to actually figure out what is wrong.

You most likely need -lwayland-client for the LDLIBS.

Thanks, I'll try to figure out later.

Best Regards,
Rasjid.

Offline

#13 2014-03-13 22:49:28

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Trilby wrote:

Well this is a completely different problem.  This is a linker error as you are using wayland functions but have not passed the relevant libs to the linker.

You'll probably be much better off using a Makefile and separating the compiling and the linking - this would make it even more clear at which step the error was.

If you post a link to the actual code we'll be able to actually figure out what is wrong.

You most likely need -lwayland-client for the LDLIBS.

Hello Trilby,

//This gives the same error.
$ gcc -o base base.c `pkg-config --cflags --libs gtk+-3.0`

/* base.c  */

#include <gtk/gtk.h>
 
int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *label;
 
    gtk_init(&argc, &argv);
 
    /* Create the main, top level window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
    /* Give it the title */
    gtk_window_set_title(GTK_WINDOW(window), "Hello, world!");
 
    /*
    ** Map the destroy signal of the window to gtk_main_quit;
    ** When the window is about to be destroyed, we get a notification and
    ** stop the main GTK+ loop by returning 0
    */
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
    /*
    ** Assign the variable "label" to a new GTK label,
    ** with the text "Hello, world!"
    */
    label = gtk_label_new("Hello, world!");
 
    /* Plot the label onto the main window */
    gtk_container_add(GTK_CONTAINER(window), label);
 
    /* Make sure that everything, window and label, are visible */
    gtk_widget_show_all(window);
 
    /*
    ** Start the main loop, and do nothing (block) until
    ** the application is closed
    */
    gtk_main();
 
    return 0;
}

Best Regards,
Rasjid

Offline

#14 2014-03-13 22:59:28

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

What do you mean that gives the same error?  The same error as in the first post, or the same as the most recent post when there was a wayland issue?

Post the actual error messages.

Also, as you didn't have pkg-config installed, you must not have the base-devel group installed.  Install base-devel before trying to go any further.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#15 2014-03-13 23:22:18

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Hello Trilby,

Trilby wrote:

What do you mean that gives the same error?  The same error as in the first post, or the same as the most recent post when there was a wayland issue?

Post the actual error messages.

Also, as you didn't have pkg-config installed, you must not have the base-devel group installed.  Install base-devel before trying to go any further.

I re-installed the base-devel group and compiling still gives error:

[rasjid@mycomputer ~]$ gcc -o base base.c `pkg-config --cflags --libs gtk+-3.0`
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libgdk-3.so: undefined reference to `wl_proxy_marshal_constructor'
collect2: error: ld returned 1 exit status

Best Regards,
Rasjid.

Offline

#16 2014-03-13 23:30:41

progandy
Member
Registered: 2012-05-17
Posts: 5,211

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

If you want gtk3 with wayland, use this:

pkg-config --cflags --libs gtk+-wayland-3.0
pkg-config --cflags --libs wayland-client # or wayland-egl?

This is a good command to list all configured libraries.

pkg-config --list-all | less

Last edited by progandy (2014-03-13 23:33:49)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#17 2014-03-14 00:20:21

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Odd, I can compile that hello world program just fine with the gcc command listed here.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#18 2014-03-14 00:22:14

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Hello,
I have to say I know almost nothing about `pkg-config  ...` things; just followed the commands from tutorials.

progandy wrote:

If you want gtk3 with wayland, use this:

pkg-config --cflags --libs gtk+-wayland-3.0
pkg-config --cflags --libs wayland-client # or wayland-egl?

This is a good command to list all configured libraries.

pkg-config --list-all | less

I have checked that my 'wayland' is installed.

But this fails:

[rasjid@mycomputer ~]$ gcc -o base base.c `pkg-config --cflags --libs wayland-client --libs wayland-egl --libs gtk+-3.0`
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libgdk-3.so: undefined reference to `wl_proxy_marshal_constructor'
collect2: error: ld returned 1 exit status

Best Regards,
Rasjid

Offline

#19 2014-03-14 00:43:02

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Trilby wrote:

Odd, I can compile that hello world program just fine with the gcc command listed here.

Then it is indeed odd. 

I don't know about compiling with GTK+, but I have used C and Netbeans IDE to write a chess playing program and it is fairly complex and runs. Which means my gcc development packages should be ok. I remember my codes do compile some time way back. Then I took a break, say 6 months, and now coming back to it. But then I reformatted my hard disk and re-installed everthing anew. Now my old codes give this error.

Rasjid.

Offline

#20 2014-03-14 03:15:33

progandy
Member
Registered: 2012-05-17
Posts: 5,211

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

I can compile it, too. I am running it in a terminal in xorg/i3. I guess the version of your wayland-package could be too old. I have wayland v1.4.0 and it works.
Something is mentioned here: https://www.redhat.com/archives/anacond … 00021.html

If you don't use wayland functions in your code and don't link directly to it, then it shouldn't be a problem that libgdk-3.so links to libwayland-client.so as long as all packages are up to date.

Last edited by progandy (2014-03-14 03:18:54)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#21 2014-03-14 09:35:03

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Hello,

progandy wrote:

I can compile it, too. I am running it in a terminal in xorg/i3. I guess the version of your wayland-package could be too old. I have wayland v1.4.0 and it works.
Something is mentioned here: https://www.redhat.com/archives/anacond … 00021.html

If you don't use wayland functions in your code and don't link directly to it, then it shouldn't be a problem that libgdk-3.so links to libwayland-client.so as long as all packages are up to date.

Thanks, SOLVED. I reinstalled wayland.

Best Regards,
Rasjid.

Offline

#22 2014-03-14 10:59:13

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

That still leaves a remaining question.  You were missing pkg-config, then later you said you "reinstalled" base-devel.  Now "reinstalling" wayland fixed this issue, but wayland is a dependency of gtk3, so certainly it was already installed, right?

How are you "reinstalling" packages?  If you are using pacman -Sy <pkg> or any combination of pacman -Sy and pacman -S, you are going to have far more serious problems.  Be sure to do regular complete updates (pacman -Syu).  I could be wrong here, but partial upgrades are the only explanation I can come up with for this set of symptoms.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#23 2014-03-14 16:32:01

chanrasjid
Banned
Registered: 2012-08-05
Posts: 19

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

Trilby wrote:

That still leaves a remaining question.  You were missing pkg-config, then later you said you "reinstalled" base-devel.  Now "reinstalling" wayland fixed this issue, but wayland is a dependency of gtk3, so certainly it was already installed, right?

How are you "reinstalling" packages?  If you are using pacman -Sy <pkg> or any combination of pacman -Sy and pacman -S, you are going to have far more serious problems.  Be sure to do regular complete updates (pacman -Syu).  I could be wrong here, but partial upgrades are the only explanation I can come up with for this set of symptoms.

It is true that I am not following strict practice now and I don't like to, or feel the need to upgrade with -Syyu or whatever. My system is not yet used for real serious thing at present.
I too was surprised that pkg-config was missing in my installation. From google, I think quite a number of people are having this <gtk/gtk.h> error as I did. My fresh installation of Archlinux automatically installed base-devel - I was surprise it is a package name. I just re-installed wayland with 'pacman -Syy' earlier; then 'pacman -S wayland'. 

But my current Archlinux is still far far ahead of my nephew's window computer which is 'not usuable' - I had to wait ages before I could start typing commands, etc! just ridiculous. 

Rasjid.

Offline

#24 2014-03-14 16:35:44

progandy
Member
Registered: 2012-05-17
Posts: 5,211

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#25 2014-03-14 18:46:08

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

Re: [SOLVED] No such file or directory #include <gtk/gtk.h>

chanrasjid wrote:

... or feel the need to upgrade with -Syyu or whatever. My system is not yet used for real serious thing at present.

If by using your system for "a real serious thing" you mean expecting it to boot up regularly, then you have nothing to worry about.  But if you chose to engage in practices that *will* break your system, please include this information in the first post of any future support threads you start.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB