Hello! As the title suggests I'm getting an undefined symbol error from the linker when I try to compile something I coded. I won't paste it all, but I'll try to show you what I believe are the most relevant pieces. So I have
menus.hmenus.cCode:typedef struct menuOps { int num; char *string[MAXOPS]; } menuOPS; ... menuOPS op_splash = {4, { "string1" , "string2" , "string3" , "string4" } }; void menu_splash(); void menu(void (*menufunc)(void), menuOPS ops);interface.hCode:#include "menus.h" void menu(void (*menufunc)(void), menuOPS ops) { ... } void menu_splash() { ... }interface.cCode:#include <...> ... int splash(); int parseOp();When compiling interface.c I get this error:Code:#include "interface.h" #include "menus.h" int splash() { ... menu(&menu_splash,op_splash); ... } int main() { ... }I've been around this for hours, mostly because I can't understand the following:Code:Undefined symbols: "_menu_splash", referenced from: _menu_splash$non_lazy_ptr in ccGrWt8C.o "_menu", referenced from: _splash in ccGrWt8C.o ld: symbol(s) not found
If I move the op_splash declaration (line in red) inside menus.c then I don't get this error (Actually I get another one about op_splash not being declared, which is understandable). Does anyone have an idea about what I'm doing wrong?
Thanks![]()



1Likes
LinkBack URL
About LinkBacks





) I did it with the best intentions.
. In the meantime I updated gcc (which was a pain as the only safe way I found to do it was by downloading the +4gb Xcode image!) and things just started compiling. Can't reason much about this, other than assuming that something was wrong with my previous installation (?). Anyway, I just wanted to clear things out. And last, thanks a bunch to all of you mike65535, anduril462, nonoob and CommonTater for taking the time to teach me something. Much obliged!