LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2005, 01:55 AM   #1
RohanShrivastav
Member
 
Registered: Sep 2004
Distribution: SuSE 9.0, Red Hat 9.0, Fedora core 1
Posts: 70

Rep: Reputation: 15
gtk program compilation error


Hello,

I am trying to learn GTK programming, and thus wrote a simple program which displays an empty window.

#include "gtk-1.2/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 compiled it using command gcc -I/opt/gnome/include/gtk-1.2/gtk/ first.c
and got the error

first.c:1:29: gtk-1.2/gtk/gtk.h: No such file or directory
first.c: In function `main':
first.c:3: error: `GtkWidget' undeclared (first use in this function)
first.c:3: error: (Each undeclared identifier is reported only once
first.c:3: error: for each function it appears in.)
first.c:3: error: `window' undeclared (first use in this function)
first.c:4: error: stray '\' in program
first.c:4: error: stray '\' in program
first.c:5: error: `GTK_WINDOW_TOPLEVEL' undeclared (first use in this function)
first.c: At top level:
first.c:9: error: stray '\2' in program

how come gcc could not find the location of gtk.h (already specified by -I option).
when i issued locate gtk.h then the output shows the same location.

what does this means? how can i remove this error?

Thanks & Regards
-Rohan
 
Old 02-16-2005, 02:01 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Try replacing the include line to:

#include <gtk/gtk.h>

and try to compile with:

gcc you_source.c -o test `pkg-config --cflags --libs gtk+-2.0`

Then if it compiles, run it with:

./test

You might also want to take a look into anjuta. It's a great IDE for C and GTK programming

Good luck!

P.S: I assume you have gtk-devel packages installed too
 
Old 02-16-2005, 02:06 AM   #3
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Oops, sorry. If you are using gtk 1.2 ratter then 2, my above post won't work. Take a look in here instead:

http://www.gtk.org/tutorial1.2/

I never used gtk1.2 before, sorry
 
Old 02-16-2005, 02:21 AM   #4
RohanShrivastav
Member
 
Registered: Sep 2004
Distribution: SuSE 9.0, Red Hat 9.0, Fedora core 1
Posts: 70

Original Poster
Rep: Reputation: 15
Thanks for your reply Megaman X,

I compiled with the command gcc you_source.c -o test `pkg-config --cflags --libs gtk+-2.0`
it reduced the errors, but still there are some..

first.c: In function `main':
first.c:5: error: stray '\' in program
first.c:5: error: stray '\' in program
first.c: At top level:
first.c:10: error: stray '\2' in program

what does this mean?

About anjuta.... i tried to install it form source while making it gave me an error saying
glib-mkenums command not found i have already placed this problem

http://www.linuxquestions.org/questi...hreadid=290794

Thanks & Regards
-Rohan
 
Old 02-16-2005, 03:22 AM   #5
RohanShrivastav
Member
 
Registered: Sep 2004
Distribution: SuSE 9.0, Red Hat 9.0, Fedora core 1
Posts: 70

Original Poster
Rep: Reputation: 15
Thanks it worked the tutorial which i am referring has \& sign instead of &,
which gave the following errors.
 
Old 02-16-2005, 07:12 AM   #6
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Cool, no problems RohanShrivastav. Congratulations .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
qt program compilation error sateeshgalla Programming 1 08-26-2005 05:33 AM
I met an error when I wrote a gtk program icoming Programming 1 03-16-2005 03:19 PM
Compilation problem with gtk+-2.4.0 Kanaflloric Linux - Software 2 06-17-2004 10:43 PM
GTK-1.2 C compilation error GabeF Programming 2 05-12-2003 08:24 AM
error during program compilation with RH7.1 Corinne Linux - Newbie 1 06-14-2001 08:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration