Having problems with using gtk

Hey, I'm having problems with compiling simple code with my gcc compiler for c++.


This is the code I'm trying to compile.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <gtk/gtk.h>

int main( int argc, char *argv[])
{

GtkWidget *window;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);

gtk_main();
return 0;
}


I type this into my terminal.
gcc -o simple simpro.cpp 'pkg-config--libs --cflags libgtk2.0-dev'


When I try to compile this code, I get this.


gcc: pkg-config--libs --cflags libgtk2.0-dev: No such file or directory
simpro.cpp:1:21: error: gtk/gtk.h: No such file or directory
simpro.cpp: In function ‘int main(int, char**)’:
simpro.cpp:6: error: ‘GtkWidget’ was not declared in this scope
simpro.cpp:6: error: ‘window’ was not declared in this scope
simpro.cpp:8: error: ‘gtk_init’ was not declared in this scope
simpro.cpp:10: error: ‘GTK_WINDOW_TOPLEVEL’ was not declared in this scope
simpro.cpp:10: error: ‘gtk_window_new’ was not declared in this scope
simpro.cpp:11: error: ‘gtk_widget_show’ was not declared in this scope
simpro.cpp:13: error: ‘gtk_main’ was not declared in this scope




i guess this file can't be found....

I did type into my terminal sudo apt-get install libgtk2.0-dev.
It did install.

Ask for extra details if needed.

Last edited on
Perhaps do a

find / -name gtk.h -print

how do i add something to the path?

That doesn't work.

Thanks though.



No one can assist me with this?
Last edited on
libgtk2.0-dev should be intalled for header files , use package manager search.
gcc = c
g++ = c++

use this ` not this ' .

type in terminal
g++ -Wall -o simple simpro.cpp `pkg-config --libs --cflags gtk+-2.0`
fix added the s to cflag


-Wall = give all warnings
Last edited on
nothing is working. I keep trying different names, headers, etc.

I'm positive I installed it.


-desktop:~/GTK/gtkmm/examples$ g++ -Wall -o simple simplegtk.cpp `pkg-config --libs --cflag gtk+-2.0`
--cflag: unknown option
simplegtk.cpp:1:19: error: gtkmm.h: No such file or directory
simplegtk.cpp:3: error: ‘Gtk’ has not been declared
simplegtk.cpp:3: error: expected constructor, destructor, or type conversion before ‘kit’
simplegtk.cpp:5: error: ‘Gtk’ has not been declared
simplegtk.cpp:5: error: expected constructor, destructor, or type conversion before ‘window’
simplegtk.cpp:7: error: ‘Gtk’ has not been declared
simplegtk.cpp:7: error: expected constructor, destructor, or type conversion before ‘(’ token


Last edited on
sorry! --cflags i forgot the s
Last edited on
Topic archived. No new replies allowed.