Re: compile multiple source file
- From: Olivier Sessink <oliviersessink gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: compile multiple source file
- Date: Fri, 31 Aug 2012 17:02:10 +0200
On 08/31/2012 04:48 PM, Rudra Banerjee wrote:
If they are in separate file, then,
$ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c
main.c: In function âmainâ:
main.c:13:5: error: âhelloâ undeclared (first use in this function)
main.c:13:5: note: each undeclared identifier is reported only once for
each function it appears in
But obviously, putting both of them together in a single file works.
How to compile while keeping them seperate
first remove the 'static' keyword before function hello(), static
functions are only called from the file itself, they are not to be
called from other files.
now create a header file hello.h that contains:
void hello( GtkWidget *widget, gpointer data );
and include that in main.c like #include "hello.h"
now you can compile each .c file, and then link the resulting .o files
to a binary.
Olivier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]