i get an undefined reference to _objc_class_name_greeter error when I compile
When I remove the line
Greeter * Hi=[[greeter alloc] init];
it compiles and all but one option works any idea what's wrong with that line
Also the error is at .data+0xa4 and correction it actually happens during linking ?
Take note that I wrote this on my iPod touch and auto correct is on all the time

Dani AI

Generated

Short summary and root cause: the linker message means the Objective-C class metadata for the named class was referenced by the compiled code but never emitted into any object file that ended up in the final link. That metadata is created by an @implementation (not by the @interface) and by compiling the implementation as Objective‑C; if the .m with the @implementation was not compiled/linked, or if the class name in the implementation does not match the name used at the call site exactly, the linker will report a missing class symbol. (swolchok.github.io)

Quick checklist to fix the specific case reported by :

  • Verify an @implementation ClassName exists for the class and that the spelling/capitalization matches the @interface and the code that sends messages to the class (Objective‑C/C identifiers are case sensitive). (vdoc.pub)

  • Make sure the implementation .m file is compiled and included on the gcc/clang command line (or in the target’s compile sources). On GNUstep/Linux prefer gnustep-config to get the right compile/link flags; e.g.:

    gcc `gnustep-config --objc-flags` main.m Greeter.m -lobjc -lgnustep-base -o main

    Putting source/object files before -l options (or using the linker option to disable “as-needed”) avoids libraries being skipped by the linker. (manpages.debian.org)

Static libraries, categories and link quirks: if the class lives inside a static archive (.a) the linker will only pull object members that resolve undefined symbols — category code can be skipped unless the class/object file is pulled. Using the recommended flags or ensuring the archive is linked correctly can be necessary (Apple’s QA explains the static‑lib/category linking behavior and workarounds). (developer.apple.com)

Practical debugging tips: inspect object and archive symbols to see whether the class metadata was emitted and what it’s named. For example:

nm -g Greeter.o | grep -i Greeter
nm -g libMyStuff.a | grep -i Greeter

An undefined reference on the linker side versus a defined symbol in the object file tells which file is missing from the link or whether the class name capitalization differs. Use those findings to add the correct .m to the build or to correct the class name in @implementation. (qastack.cn)

I have solved the general problem but not my specific problem I'm compiling on Linux so I have to invoke a few extra gcc options
Ex
gcc -o main main.m -lobjc -i /usr/include -L(I'll post this in a little while) -lgnu-base
Ill finish the whole thing in a sec

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.