user1360503
user1360503

Reputation: 11

Compilation error with makefile and gtk+

I have a big problem with gtk+

When i compile with my makefile, i have :

gcc Affichage.c -W -Wall `pkg-config --cflags --libs gtk+-2.0`
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: dans la fonction « _start »:
(.text+0x18): référence indéfinie vers « main »
collect2: erreur: ld a retourné 1 code d'état d'exécution
make: *** [Affichage.o] Erreur 1

In Makefile, the line is :

Affichage.o: Affichage.c
    gcc Affichage.c -W -Wall `pkg-config --cflags --libs gtk+-2.0`

Are you an idea ?

PS : Sorry for my bad English... I'm French

Upvotes: 0

Views: 334

Answers (1)

krokoziabla
krokoziabla

Reputation: 775

I believe your intention was to make Affichage.o only a part of a big program. If it really was then you should have added -c flag to the rule you've given. This way it would have requested GCC to only compile Affichage.c but not link with CRT (assuming that you have a separate rule which links the whole of your program). And in that case you do not need to pass --libs flag to pkg-config. You should move it to the separate rule for linking.

In your case LD says it misses the entry point in your program (i.e. main function). I believe it resides elsewhere, not in Affichage.c file.

Upvotes: 1

Related Questions