C undefined reference to `some_foo '

I have 3 files in my gtk + application:

main.c:

#include <gtk/gtk.h>
#include <glib/gi18n.h>

#include "mainwindow.h"

int main(int argc, char** argv)
{
    MainWin*      win;
    GError* err = NULL;
    int a = 0;
    a = some_foo();
    gtk_main();
    return 0;
}

mainwindo.h

#include <gtk/gtk.h>


typedef struct _MainWin
{
    GtkWindow parent;

} MainWin;

GtkWidget* main_win_new();

int some_foo();

MainWindow.c

#include "mainwindow.h"


int some_foo()
{
  return 1;
}

When I try to call some_fooin the main function and try to compile i, see the error: undefined reference to `some_foo '. What's wrong?

Thank.

+3
source share
1 answer

You probably don't include MainWindow.cin your assembly. For instance. in a shell, it might look like this:

gcc $ALL_THE_FLAGS main.c MainWindow.c
+3
source

Source: https://habr.com/ru/post/1746750/


All Articles