Funktions probleme
-
Hi Leute,
vielleicht sollte ich erstmal sagen dass ich in c ziemlich eingerostet
bin mein letztes programm ist bestimmt 4 Jahre her.Aber nun zu meiner frage:
Ich habe eine Funktion die ein Typedef zurückgibt und wenn ich versuche die
Funktion zu benutzen bekomme ich folgende Fehlermeldung.gcc config.c -c
gcc -lncurses -o fdedit main.c
/tmp/ccNoGW2j.o(.text+0xff): In functionmain': : undefined reference to
GetConfig'
collect2: ld returned 1 exit status
make: *** [fdedit] Error 1main:
#include <ncurses.h> #include "config.h" int main(int argc, char** argv) { Config_S main_config = {"~/.fdedit", 0}; main_config = GetConfig(main_config); GetConfig(Config_S config_in); return 0; }
config.h
#ifndef _CONFIG #define _CONFIG /* Definitition of a struct that will keep all the configuration */ typedef struct { char config_file[256]; int ls_file_size; } Config_S; /* Get the configuration out of the file specified in Config_s */ Config_S GetConfig(Config_S config_in); #endif
config.c
#include "config.h" Config_S GetConfig(Config_S config_in) { Config_S config_out; config_out = config_in; /* open the configuration file (will be impl. later) */ return config_out; };
Da es ja vielleicht auch an meinem Makefile scheitert:
CC := gcc CURSES := -lncurses DEBUG := # Define the targets fdedit: main.c config.o $(CC) $(CURSES) -o fdedit main.c config.o: config.c $(CC) config.c -c
Danke!
-
du hast config.o zwar kompiliert aber vergessen dann in fdedit zu linken. du hast es lediglich als abhängigkeit angegeben.
-
Danke genau das wars!