int main(int argc, char *argv[])
{
WID *p_MainWindow;
gtk_init(&argc, argv);
p_MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(p_MainWindow), "destroy", GTK_SIGNAL_FUNC(killall), NULL);
gtk_main();
}
or
int main(int argc, char *argv[])
{
WID p_MainWindow;
gtk_init(&argc, argv);
&p_MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(&p_MainWindow), "destroy", GTK_SIGNAL_FUNC(killall), NULL);
gtk_main();
}
gtk_window_new() returns an address so you need a pointer.
]]>That's an error in your code then. Could you post the main function that doesn't compile?
#include <gtk/gtk.h>
#define WID GtkWidget
void killall();
int main(int argc, char *argv[])
{
WID p_MainWindow;
gtk_init(&argc, argv);
p_MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(hauptfenster), "destroy", GTK_SIGNAL_FUNC(killall), NULL);
gtk_main();
}
void killall()
{
gtk_main_quit();
}
well, I have no clue about native gtk2 stuff but 'hauptfenster' should be
'p_MainWindow' I guess. Anyway it gives me an error about somethin'
wrong in gtk_window_new() then. As I said, no idea abou gtk API
-neri
]]>tobias@buran learn_c]$ gcc -Wall -g 01_gtk2_test.c -o 01_gtk2_test `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
01_gtk2_test.c: In function 'main':
01_gtk2_test.c:10: warning: passing argument 2 of 'gtk_init' from incompatible pointer type
01_gtk2_test.c:12: error: incompatible types in assignment
01_gtk2_test.c:13: error: 'hauptfenster' undeclared (first use in this function)
01_gtk2_test.c:13: error: (Each undeclared identifier is reported only once
01_gtk2_test.c:13: error: for each function it appears in.)
01_gtk2_test.c:16: warning: control reaches end of non-void function
this is how I compiled it.
gcc -Wall -g 01_gtk2_test.c -o 01_gtk2_test `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
get the same as root.
-neri
]]>I started changing the permissions in /usr/X11R6/include and /usr/include,
but it seems there is still more to change.
I wonder how these perms can be set so wrong? I didn't alter them manually (eg. gtk2 was freshly installed). And they appear like this :
[starthis@morpheus X11R6]$ ls -al
total 28
drwxr-xr-x 6 root root 4096 2005-03-27 21:59 .
drwxr-xr-x 13 root root 4096 2002-09-04 18:07 ..
drwxr-xr-x 2 root root 4096 2005-03-31 17:19 bin
drwx------ 6 root root 4096 2005-03-27 21:59 include
drwxr-xr-x 6 root root 8192 2005-04-09 18:52 lib
drwxr-xr-x 7 root root 4096 2005-02-18 17:41 man
After changing the permissions to 755 on the entire /usr/include & /usr/X11R6/include all went fine 8)
]]>gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
I did make sure that everything was on one line in the console, however.
]]>Thats why I wonder if I'm the only one with this problem. Can anybody test if they can compile this hello world example?
]]>After a 'pacman -S gtk2' (there seems to be no gtk2-devel package) I thought I was all set to compile a hello world example(http://www.gtk.org/tutorial/sec-compiling.html)...alas.
While the pkg-config output for "pkg-config --cflags gtk+-2.0" and "pkg-config --libs gtk+-2.0" seems correct, I get a huge amount of errors.
It looks pretty much like this :
http://www.wer-weiss-was.de/theme158/ar … 69167.html
This was the only simular problem I could find online, unfortunatly I don't know how to apply the answer in that thread. (It suggests the linker can't find the gtk libraries)
Is there some configuration required after installing the gtk2 package? if so, I didn't find any documentation about it in forum/wiki. Since no one else posted this problem, I suppose normally it works out-of-the box?
All help is very appreciated. I'd love to see that hello world gtk2 example pop up
]]>