Pinecone_
August 5th, 2009, 11:56 AM
Hi,
I'm new to ubuntu and C++, I still have to use Windows at school though, so I thought I'd try developing cross platform stuff with c++ and gtk, but got stopped in my tracks at the first steps. I found a tutorial somewhere (cant remember where now) which had this example code:
#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 saved the above as Test.cpp and ran this:
$ g++ Test.cpp -o Testwhich gave me this:
Test.cpp:1:21: error: gtk/gtk.h: No such file or directory
Test.cpp: In function ‘int main(int, char**)’:
Test.cpp:6: error: ‘GtkWidget’ was not declared in this scope
Test.cpp:6: error: ‘window’ was not declared in this scope
Test.cpp:8: error: ‘gtk_init’ was not declared in this scope
Test.cpp:10: error: ‘GTK_WINDOW_TOPLEVEL’ was not declared in this scope
Test.cpp:10: error: ‘gtk_window_new’ was not declared in this scope
Test.cpp:11: error: ‘gtk_widget_show’ was not declared in this scope
Test.cpp:13: error: ‘gtk_main’ was not declared in this scope
So I'm guessing I haven't set up gtk to work right with g++ or something.
I know g++ works, as i compiled this earlier (from another tutorial)
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
So my question is, what do i need to do to get g++ to find the header files and such for compiling gtk things? Also, what would I need to keep in mind in order to compile things for windows as well? And are there any good tutorials that explain cross platform development with gtk, which explain steps compiling on windows and ubuntu (or any other linux which the steps would be the same or similar) for someone who has never used c++ before?
It's alot to ask I think, but thanks in advance for any help.
I'm new to ubuntu and C++, I still have to use Windows at school though, so I thought I'd try developing cross platform stuff with c++ and gtk, but got stopped in my tracks at the first steps. I found a tutorial somewhere (cant remember where now) which had this example code:
#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 saved the above as Test.cpp and ran this:
$ g++ Test.cpp -o Testwhich gave me this:
Test.cpp:1:21: error: gtk/gtk.h: No such file or directory
Test.cpp: In function ‘int main(int, char**)’:
Test.cpp:6: error: ‘GtkWidget’ was not declared in this scope
Test.cpp:6: error: ‘window’ was not declared in this scope
Test.cpp:8: error: ‘gtk_init’ was not declared in this scope
Test.cpp:10: error: ‘GTK_WINDOW_TOPLEVEL’ was not declared in this scope
Test.cpp:10: error: ‘gtk_window_new’ was not declared in this scope
Test.cpp:11: error: ‘gtk_widget_show’ was not declared in this scope
Test.cpp:13: error: ‘gtk_main’ was not declared in this scope
So I'm guessing I haven't set up gtk to work right with g++ or something.
I know g++ works, as i compiled this earlier (from another tutorial)
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
So my question is, what do i need to do to get g++ to find the header files and such for compiling gtk things? Also, what would I need to keep in mind in order to compile things for windows as well? And are there any good tutorials that explain cross platform development with gtk, which explain steps compiling on windows and ubuntu (or any other linux which the steps would be the same or similar) for someone who has never used c++ before?
It's alot to ask I think, but thanks in advance for any help.