Click to See Complete Forum and Search --> : error compiling gtk program


hfawzy
08-26-2002, 11:43 AM
i tried to compile a gtk program using this command:


cc `pkg-config --cflags --libs gtk+-2.0` program.c -o program

but it gives me this error:


/usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/../../../crt1.o: In function `_start':
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

any ideas?
Thank you

bwkaz
08-26-2002, 01:07 PM
It thinks your program.c file doesn't have a main() function -- is this correct?

hfawzy
08-26-2002, 02:33 PM
Yes, my program doesn't have a main function.. (In fact, it's not my program... I was trying to compile the demos that come with gtk2). Do i have to add a main function or is there an option to tell the compiler that this program does'nt contain a main() function...
thank you :)

Wallex
08-26-2002, 03:14 PM
One of the basics of C programming... you need a main. You could just write a threeline main function that calls the function you want to test or something like that. Without the main function, the compiler won't know where the program is supposed to begin execution.

hfawzy
08-27-2002, 08:34 AM
thanks for your help, Wallex :cool: