compile multiple source file



I have two file:

#THE MAIN###
#include <gtk/gtk.h>

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    button = gtk_button_new_with_label ("Hello World");
    g_signal_connect (button, "clicked",
                      G_CALLBACK (hello), NULL);
    gtk_container_add (GTK_CONTAINER (window), button);
    gtk_widget_show (button);
    gtk_widget_show (window);
    gtk_main ();
    
    return 0;
}


#########hello.c
#include <gtk/gtk.h>
static void hello( GtkWidget *widget,
                   gpointer   data )
{
    g_print ("Hello World\n");
}


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
?





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]