How do I use the Objective-C bindings? When trying to build a simple example program, I get:
chiyo:/tmp% gcc -o test test.m -lFoundation /tmp/ccowH8qL.o: In function `main': test.m:(.text+0x1c0): undefined reference to `really_free_svalue' /tmp/ccowH8qL.o:(.data+0x334): undefined reference to `__objc_class_name_OCPikeInterpreter' collect2: ld returned 1 exit status chiyo:/tmp%
Ok, I obviously need to create some library. But how? The only part of the build system which touches "OCPikeInterpreter" appears to be the rule "framework", but making framework does not work:
chiyo:~/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc% make framework Compiling OCPikeInterpreter.m make[1]: Entering directory `/home/marcus/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc' make[1]: Leaving directory `/home/marcus/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc' make[1]: Entering directory `/home/marcus/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc' make[1]: Leaving directory `/home/marcus/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc' Linking Pike.framework gcc: Cocoa: No such file or directory gcc: dynamic_lookup: No such file or directory gcc: 7.7: No such file or directory gcc: @executable_path/../Frameworks/Pike.framework/Pike: No such file or directory gcc: unrecognized option '-current_version' make: *** [framework] Error 1 chiyo:~/Pike/7.7/build/linux-2.6.22-12-powerpc-ppc%
I think this needs some work before it can go into 7.8.
Maybe not related, but if "-lFoundation" refers to /System/Library/Frameworks/Foundation.framework I guess you want "-framework Foundation" instead.
Huh? I don't have any /System in my Linux installation. -lFoundation refers to /usr/lib/libFoundation.so.
That's my code... what platform/runtime are you using? For an example of how to use the embedding framework, see the tail end of src/ OC_PikeInterpreter.m. I also put some notes together on the Pike wiki:
http://www.gotpike.org/PikeWiki/index.pike/PikeDevel/Framework
As for your framework building problems, I don't have access to a Linux box, so the framework may use NEXT specific options. Sounds like non-Apple gcc doesn't support some of the bundle/framework specific compiler options (such as -framework -current_version and - install_name). If anyone can provide that information, I might be able to make things work.
Bill
On Oct 6, 2007, at 9:50 AM, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
How do I use the Objective-C bindings? When trying to build a simple example program, I get:
I'm using gcc on Linux/PPC, and I installed libfoundation1.0-dev as the example seemed to need it. The example in OC_PikeInterpreter.m compiles like the example I already have (after I change <Pike/...> to <pike/...> in the #import statement), but I still need some library to link it against.
I don't know this bundle/framework concept, I think you should just create a shared library (libOCPike.so or whatever).
I copied the rule for libpike.so, making it
$(TMP_BINDIR)/smartlink "$(LDSHARED)" $(LDFLAGS) -o libOCpike.@SO@ \ OCPikeInterpreter.o $(OBJ) `cat modules/linker_options @STATIC_POST_MODULES_LINKOPTS@` \ $(LIBS);
This gives me a shared library which almost does the trick. However, there are some unresolved symbols still:
/tmp/libOCpike.so: undefined reference to `__gnu_objc_personality_v0' /tmp/libOCpike.so: undefined reference to `objc_exception_throw'
Hmm...
pike-devel@lists.lysator.liu.se