View Full Version : Set up probs' with Anjuta and GTK
blastradius
January 7th, 2006, 10:02 AM
HI
Newbie question.
I've installed Anjuta, gained a reasonable idea of C and C++ and decided
to have a look at GTK and SDL. I've downloaded a basic example of SDL
and i've worked through the 'Starting off in Anjuta' tutorial.
Problem comes when i try to compile and i get a red strike through this
line;-
#include <gtk/gtk.h>. This causes errors throughout the program.
I get the same thing when i try to compile my SDL example and this
line:-
#include <sdl/sdl.h>. Same problem.
I've checked that GTK and SDL are installed on my system (Ubuntu Breezy)
and i don't know how to set Anjuta up to use these libs.
Please help.
Eric
P.S. Could someone explain the difference between SDL and STL, and what should i use to get into 2D graphics? (i did say i was a new coder!!)
Thanks
Hanj
January 7th, 2006, 01:58 PM
Make sure you have the dev versions of GTK and SDL. If you already have, you should post the error messages you're getting (which is always a good idea when asking about compilation problems).
STL (Standard Template Library) is standard C++ library (i.e. you don't have to install it yourself, it comes with the compiler). It provides datastructures for linked lists and dynamic-size arrays.
SDL (Simple DirectMedia Layer) is a cross-platform library for 2D graphics.
blastradius
January 7th, 2006, 02:30 PM
Thanks for the reply, i have got all the devs installed so here's the example GTK code:-
#include <gtk/gtk.h>
..
...
static gboolean delete_event( GtkWidget *widget,
GdkEvent *event,
gpointer data )
{
return FALSE;
}
static void destroy( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();
}
int main( int argc, char *argv[] )
{
GtkWidget *window_Widget;
...
..
gtk_init (&argc, &argv);
//instantiate principal parent window
window_Widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window_Widget), "Example GTK Skeleton");
// Connect callbacks to main window
g_signal_connect (G_OBJECT (window_Widget), "delete_event",
G_CALLBACK (delete_event), NULL);
g_signal_connect (G_OBJECT (window_Widget), "destroy",
G_CALLBACK (destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window_Widget), 10);
// Call to container widget
vBox_Widget = gtk_vbox_new (.......);
...
..
// Attach widgets to container widget.
gtk_box_pack_start (GTK_BOX (vBox_Widget), new_component_1_Widget, TRUE, TRUE, 0);
...
..
// Attach container to main window.
gtk_container_add (GTK_CONTAINER (window_Widget), vBox_Widget);
...
..
gtk_widget_show (vBox_Widget);
gtk_widget_show (window_Widget);
gtk_main ();
return 0;
}
If i run compile i get these errors:-
Compiling file: sdl_blit_sprite.cpp ...
g++ -c "sdl_blit_sprite.cpp" -o "sdl_blit_sprite.o"
sdl_blit_sprite.cpp:1:21: error: gtk/gtk.h: No such file or directory
sdl_blit_sprite.cpp:2: error: expected unqualified-id before ‘.’ token
sdl_blit_sprite.cpp:11: error: variable or field ‘destroy’ declared void
sdl_blit_sprite.cpp:11: error: ‘GtkWidget’ was not declared in this scope
sdl_blit_sprite.cpp:11: error: ‘widget’ was not declared in this scope
sdl_blit_sprite.cpp:12: error: ‘gpointer’ was not declared in this scope
sdl_blit_sprite.cpp:12: error: initializer expression list treated as compound expression
sdl_blit_sprite.cpp:13: error: expected ‘,’ or ‘;’ before ‘{’ token
sdl_blit_sprite.cpp: In function ‘int main(int, char**)’:
sdl_blit_sprite.cpp:19: error: ‘GtkWidget’ was not declared in this scope
sdl_blit_sprite.cpp:19: error: ‘window_Widget’ was not declared in this scope
sdl_blit_sprite.cpp:20: error: expected primary-expression before ‘...’ token
sdl_blit_sprite.cpp:20: error: expected `;' before ‘...’ token
sdl_blit_sprite.cpp:27: error: ‘GTK_WINDOW_TOPLEVEL’ was not declared in this scope
sdl_blit_sprite.cpp:27: error: ‘gtk_window_new’ was not declared in this scope
sdl_blit_sprite.cpp:28: error: ‘GTK_WINDOW’ was not declared in this scope
sdl_blit_sprite.cpp:28: error: ‘gtk_window_set_title’ was not declared in this scope
sdl_blit_sprite.cpp:32: error: ‘G_OBJECT’ was not declared in this scope
sdl_blit_sprite.cpp:33: error: ‘delete_event’ was not declared in this scope
sdl_blit_sprite.cpp:33: error: ‘G_CALLBACK’ was not declared in this scope
sdl_blit_sprite.cpp:33: error: ‘NULL’ was not declared in this scope
sdl_blit_sprite.cpp:33: error: ‘g_signal_connect’ was not declared in this scope
sdl_blit_sprite.cpp:38: error: ‘GTK_CONTAINER’ was not declared in this scope
sdl_blit_sprite.cpp:38: error: ‘gtk_container_set_border_width’ was not declared in this scope
sdl_blit_sprite.cpp:42: error: ‘vBox_Widget’ was not declared in this scope
sdl_blit_sprite.cpp:42: error: expected primary-expression before ‘...’ token
sdl_blit_sprite.cpp:42: error: ‘gtk_vbox_new’ was not declared in this scope
sdl_blit_sprite.cpp:44: error: expected primary-expression before ‘...’ token
sdl_blit_sprite.cpp:44: error: expected `;' before ‘...’ token
sdl_blit_sprite.cpp:50: error: expected primary-expression before ‘...’ token
sdl_blit_sprite.cpp:50: error: expected `;' before ‘...’ token
sdl_blit_sprite.cpp:57: error: expected primary-expression before ‘...’ token
sdl_blit_sprite.cpp:57: error: expected `;' before ‘...’ token
sdl_blit_sprite.cpp:61: error: ‘gtk_widget_show’ was not declared in this scope
sdl_blit_sprite.cpp:63: error: ‘gtk_main’ was not declared in this scope
Completed ... unsuccessful
Total time taken: 1 secs
I've probably gone over the top listing everything, but i wouldn't know what to leave out.
Thanks again for your help!
Hanj
January 7th, 2006, 02:51 PM
Well, the code looks OK, but it seems the compiler can't find the gtk headers. If you installed libgtk2.0-dev using apt-get you should have the file gtk.h in /usr/include/gtk-2.0/gtk. If the file isn't there you could try reinstalling the lib. If it is there, there might be something wrong with Anjuta's include path. Maybe someone with more experience on Anjuta can help you more.
blastradius
January 7th, 2006, 03:45 PM
Hi
The gtk file is there (2.0 + 2.4) so i guess it's Anjuta having problems finding the libs.
Thanks for your help.
Lews Therin
January 8th, 2006, 10:36 PM
HI
Newbie question.
I've installed Anjuta, gained a reasonable idea of C and C++ and decided
to have a look at GTK and SDL. I've downloaded a basic example of SDL
and i've worked through the 'Starting off in Anjuta' tutorial.
Problem comes when i try to compile and i get a red strike through this
line;-
#include <gtk/gtk.h>. This causes errors throughout the program.
I get the same thing when i try to compile my SDL example and this
line:-
#include <sdl/sdl.h>. Same problem.
I've checked that GTK and SDL are installed on my system (Ubuntu Breezy)
and i don't know how to set Anjuta up to use these libs.
Please help.
Eric
P.S. Could someone explain the difference between SDL and STL, and what should i use to get into 2D graphics? (i did say i was a new coder!!)
Thanks
Somewhere in Anjuta should be an option for compiler options and linker options. For GTK+, these are the options to use starting out. Include the backticks, they are needed.
Compiler: `pkg-config gtk+-2.0 --cflags`
Linker: `pkg-config gtk+-2.0 --libs`
blastradius
January 9th, 2006, 03:26 AM
Thanks for your reply.
I've found - 'settings/compiler and linker options', within this there is an options tab (along with a few others like 'include paths' + library paths'). The options tab has fields for 'compiler flags + linker flags + additional libraries'.
Is it the fileds for flags i need to fill in? and do i need to enter anything in the other tabs?
Again, thanks for your help.
Lews Therin
January 9th, 2006, 06:51 PM
Thanks for your reply.
I've found - 'settings/compiler and linker options', within this there is an options tab (along with a few others like 'include paths' + library paths'). The options tab has fields for 'compiler flags + linker flags + additional libraries'.
Is it the fileds for flags i need to fill in? and do i need to enter anything in the other tabs?
Again, thanks for your help.
Those look right. You only need to fill in compiler flags and linker flags as far as I know.
flerchjj
December 10th, 2007, 02:06 AM
Try installing glib packages with the Synaptic Package manager. This seemed to help resolve some similar errors for me.
jespdj
December 10th, 2007, 05:24 PM
flerchjj, why did you respond to a thread that is almost two years old?
kuscsik
March 12th, 2008, 10:15 AM
Probably he posted the answer because someone else (like me) may still have the same problem.
no_mosquitos
April 4th, 2008, 07:18 AM
This manual have some info:
http://www.anjuta.org/documents/C/anjuta-advanced-tutorial/index.html#simple-example-without-anjuta
JBull
June 16th, 2008, 11:58 PM
flerchjj, why did you respond to a thread that is almost two years old?
Because it will help folks like me solve the same problem.
Thanks for the solution, flerchjj. It worked.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.