discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HOWTO: ARC (libobjc2) and libdispatch on Ubuntu 12.04 Server


From: Niels Grewe
Subject: Re: HOWTO: ARC (libobjc2) and libdispatch on Ubuntu 12.04 Server
Date: Sun, 12 Aug 2012 20:44:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4

Hi Patryk,

Am 11.08.2012 18:52, schrieb Patryk Laurent:
> Below are some step-by-step instructions on installing libobjc2 and 
> libdispatch on Ubuntu 12.04 server.

Many thanks for the write-up. I didn't try it out, put from looking over
it, it does seem like it should work ;-). I have two remarks, though:

> # --------------------------------------------------------------------
> # 1) Install GNUstep Make a first time.
> # --------------------------------------------------------------------


I do seem to recall that this shouldn't be necessary anymore. If you
build libobjc2 using `make -f Makefile', it should build fine and you
can skip right to step 3.


> # --------------------------------------------------------------------
> # Testing
> # --------------------------------------------------------------------
> # Plain C: When not compiling with libobjc2 (just plain C) on Ubuntu you must 
> add -lBlocksRuntime
> # --------------------------------------------------------------------
> 
> clang -o hi helloGCD.c -fblocks -ldispatch -lBlocksRuntime
> ./hi
> 
> clang -o hi helloGCD.c -fblocks -ldispatch
> # /usr/bin/ld: /tmp/helloGCD-eXxFYY.o: undefined reference to symbol 
> '_NSConcreteGlobalBlock'
> # /usr/bin/ld: note: '_NSConcreteGlobalBlock' is defined in DSO 
> /usr/lib/libBlocksRuntime.so.0 
> # so try adding it to the linker command line
> # /usr/lib/libBlocksRuntime.so.0: could not read symbols: Invalid operation
> # clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> 
> 
> 
> # --------------------------------------------------------------------
> # Compiling Objective C with ARC and blocks and libdispatch
> # --------------------------------------------------------------------
> # Note: do not use -lBlocksRuntime here since Apple on is not 
> # compatible with the libobjc2 one which has its own. (Note from 
> # David Chisnall)
> # --------------------------------------------------------------------
> 
> clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -fobj-arc 
> -fobjc-nonfragile-abi -fblocks  helloGCD_objc.m Fraction.m -o test -lobjc 
> -lgnustep-base -ldispatch
> ./test


The way you're building libdispatch is a bit rotten, since -- as you
mention in passing -- you can either link it with libBlocksRuntime or
with libobjc2 but not both at the same time. This will cause you trouble
if you're trying to link a C library that uses libdispatch (and
libBlocksRuntime) with Objective-C code using libobjc2. There are two
possible workarounds for this problem. You can a) apply my patch from
[0] to libdispatch in order for it to use libobjc2 as its native blocks
runtime (and never even bother to install libBlocksRuntime), or you can
use Mark Heily's branch of libBlocksRuntime [1] that turns all the
exported symbols into weak symbols so that libobjc2 can override them
(he somewhat promised that this would be merged into trunk, but it
doesn't seem that he got around to doing that yet).


But anyways: Is there any chance that you could put your howto up on the
wiki, so that is accessible for collaborative editing?

Cheers,

Niels


[0]
http://www.halbordnung.de/~niels.grewe/gnustep/libdispatch-libobjc2.patch
[1] svn://mark.heily.com/libBlocksRuntime/branches/objc2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]