[Top][All Lists]

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

Re: Getting Objective-C 2.0 working

From: Laurent Michel
Subject: Re: Getting Objective-C 2.0 working
Date: Fri, 18 May 2012 13:41:24 -0400

I'm answering my own email.....


Do *not* use GNUstep-startup

Download the four individual packages (Make/Base/GUI/Backend) and

#1 : compile / install make
#2 : compile / install libobjc2
#3 : compile / install the three remaining (Base/Gui/Backend)


It works ;-)

Very happy camper.


PS/ Only issue I have now is in my code:

Calling [GSMutableSet -enumerateObjectsUsingBlock:] with incorrect signature.  Method has address@hidden:4^{?=^vii^?}8, selector has address@hidden:address@hidden

This happens when the following runs (and that runs fine on MacOS 10.7.x)

   __block float h = 0.0;
   NSSet* theConstraints = _cv[[x getId]];   
   [theConstraints enumerateObjectsUsingBlock:^void(id obj, BOOL *stop) {
      if ([obj nbUVars] - 1 > 0)
         h += _w[[obj getId]];
   return h / [x domsize];

That enumerateObjects looks innocuous to me.

On May 18, 2012, at 12:03 PM, Laurent Michel wrote:

Dear Eric (and everybody else reading! ;-)),

One more question, if I can abuse of your time some more....

To make a long story short, I apparently failed to get GNUstep compiled with the newer libobjc2 runtime you pointed me at, but my own
code does compile against that runtime. However, my code does not link succesfully against the GNUstep I cobbled together on Ubuntu. 

Any attempt to build GNUstep with the gcc tool suite pulls a different (older) libobjc runtime and the two are incompatible. So I eventually decide to remove all the tools that came with ubuntu and try to build GNUstep with clang. 

Note that I successfully build the libobjc2 you pointed me to. 

To attempt a build of GNUstep:

1. export CC=clang
2. ./InstallGNUstep

Step #2 fails to succesffully configure GNUstep though. Here is the report it produces at the end:

* Startup configuration report                                      *
W107 Warning
No XML library support was found. The GNUstep uses XML for many basic
functions, such as reading/writing property lists. XML will automatically
be disabled, but this is probably not what you want. If possible you should
stop installation and install an xml library.
W125 Warning 
The OpenSSL package (libcrypto, etc) is needed to access https connections
with NSURL and for other purposes. This package is optional so you are
not required to install it.
E150 Error
You do not have the GNU Objective-C compiler installed
Check to make sure you have a full installation of the GCC
compiler that includes the Objective-C headers and libraries
W272 Warning
You do not have a recent version of the libobjc library. Startup
will install one.
E281 Error
I don't seem to be able to use your Objective-C compiler to produce
working binaries!  Please check your Objective-C compiler installation.
For gcc-3.0.x make sure that your compiler's libgcc_s and libobjc
can be found by the dynamic linker - usually that requires you to add
the directory given by gcc to your

1. I do have libxml2 and libxml2-dev
2. I do lhave libopenssl and its dev package as well
3. Scrolling up, I can see that the configure invoked by this script did try to use clang. 

For instance:

checking for library combo... gnu-gnu-gnu
checking for prefix... checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
configure: Configuring on linux-gnu
checking compiler version... gcc major version is 4
checking for apple compiler... no
checking for ar... ar
checking for ld... ld
checking for dlltool... no
checking for gawk... no
checking for awk... awk
checking for patch... patch
checking for ranlib... ranlib
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking for whoami... /usr/bin/whoami
checking for gmake... no
checking for make... make
checking make version > 3.75... yes GNU Make 3.81
checking broken make... ok
checking binutils version > 2.9... yes GNU ld (GNU Binutils for Ubuntu) 2.22
checking iconv version > 2.1... yes 2.15
checking iconv support... yes, in libc
checking for xml2-config... /usr/bin/xml2-config
checking for libxml - version >= 2.3.0... no
*** Could not run libxml test program, checking why...
checking the Objective-C runtime... GNU

It also says it is going to try to use the GNU version of the objective-C runtime. So I suspect that he can't locate the newer one I gave
even though I added it in ldconfig:

address@hidden:/usr/local/src/gnustep-startup-0.28.0# ldconfig -p|grep objc (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/ (libc6) => /usr/local/lib/

So it is present. 

I checked the header and:

address@hidden:/usr/local/src/gnustep-startup-0.28.0/build# updatedb
address@hidden:/usr/local/src/gnustep-startup-0.28.0/build# locate objc.h

Namely, there is only one objc.h (the good one)

Looking inside the log, I see:

configure:6154: checking whether objc has thread support
configure:6186: clang -o conftest -g -O2 -x objective-c -I/usr/local/src/gnustep-startup-0.28.0 -fgnu-runtime   conftest.c -lobjc -lpthread >&5
In file included from conftest.c:14:
/usr/local/src/gnustep-startup-0.28.0/config/config_thread.m:5:10: fatal error: 'objc/NXConstStr.h' file not found
#include <objc/NXConstStr.h>
1 error generated.
configure:6186: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNUstep Setup"
| #define PACKAGE_TARNAME "gnustep-setup"
| #define PACKAGE_VERSION "0.20.0"
| #define PACKAGE_STRING "GNUstep Setup 0.20.0"
| #define PACKAGE_BUGREPORT "address@hidden"
| #define PACKAGE_URL ""
| #define HAVE_ICONV 1
| #define HAVE_OPENSSL_SSL_H 1
| #define HAVE_LIBCRYPTO 1
| #define HAVE_OBJC_OBJC_H 1
| #define HAVE_CALLBACK_H 1
| /* end confdefs.h.  */
| #include "/usr/local/src/gnustep-startup-0.28.0/config/config_thread.m"
configure:6348: result: no

and /usr/local/include/objc does not contain anything named NXConstStr.h

address@hidden:/usr/local/src/gnustep-startup-0.28.0/build# ls /usr/local/include/objc/
Availability.h    capabilities.h  encoding.h  objc-api.h  objc-auto.h  Object.h    runtime-deprecated.h  slot.h
blocks_runtime.h  developer.h     hooks.h     objc-arc.h  objc.h       Protocol.h  runtime.h             toydispatch.h

So... what is going on ? is the configure picking the wrong runtime? 

Any hint at how to diagnose this? 

Thanks again!

(Aside on the XML / openssl issue)

(For XML:
I have libxml2 installed (including dev package of course). The configuration fails though with this in the log for libxml2:

configure:4208: checking for xml2-config
configure:4226: found /usr/bin/xml2-config
configure:4239: result: /usr/bin/xml2-config
configure:4293: checking for libxml - version >= 2.3.0
configure:4472: gcc -o conftest -g -O2 -I/usr/include/libxml2   conftest.c /i386-linux-gnu -lxml2  >&5
gcc: error: /i386-linux-gnu: No such file or directory

The compilation command constructed is clearly incorrect. 

Then I have a second error related to openssl:

configure:4989: gcc -o conftest -g -O2   conftest.c -lsocket  -lcrypto  >&5
/usr/bin/ld: cannot find -lsocket

There is no socket lib. sockets are part of libc no?

On May 17, 2012, at 11:09 PM, Eric Wasylishen wrote:

Hi Laurent,

To use blocks in GNUstep you need to use the GNUstep Objective-C runtime, a.k.a. libobjc2, whose releases are available here:  

Unfortunately, I don't think this library is available in debian/ubuntu (though I could be wrong!). Confusingly, the package called "libobjc2" in debian/ubuntu is unrelated to the GNUstep Objective-C runtime and doesn't support blocks.

So, as far as I know, what you'll need to do is remove the Ubuntu packages for gnustep you installed, then install libobjc2 and GNUstep again from the source packages. (Latest gnustep releases are at:

The Etoile ObjectiveC2 framework no longer exists and isn't something you need to worry about. IIRC, the initial support in GNUstep for the modern Objective-C runtime api's was started in that framework in Etoile, but that code has since been merged into GNUstep and libobjc2.

Hope this helps,


On 2012-05-17, at 9:27 PM, Laurent Michel wrote:

Dear All,

I develop on MaOS and would love to port my code to Linux. Essentially, I use Objective-C 2.0 with clang as a compiler.
I created an Ubuntu 12.04 VM under VMWare and installed GNUStep through that channel. I compiled a silly hello world and that worked fine.
My problems started when I tried to compile my own code which makes *heavy* use of Objective-C blocks. I always end-up seeing this message:

clang -I/usr/GNUstep/System/Library/Headers  -fblocks -fobjc-nonfragile-abi -c CPFactory.m
In file included from CPFactory.m:27:
In file included from ./CPFactory.h:27:
In file included from /usr/GNUstep/System/Library/Headers/Foundation/Foundation.h:30:
/usr/GNUstep/System/Library/Headers/GNUstepBase/GSVersionMacros.h:287:14: fatal error: 'objc/blocks_runtime.h' file not found

namely, it cannot find objc/blocks_runtime.h

I started googling around and I found lots of conflicting information on the topic as well as reference to Etoile, and ObjectiveC2 (a framework) but it seems largely incompatible with GNUStep. I'll looking for some directions to get going with a simple code that uses blocks. For instance, a silly test like:

#import <Foundation/NSObject.h>

int foo(int (^b)(int)) {
 return b(5);

int main() {

 int y = 10;
 int z = foo(^(int x) {
return y + x;
 NSLog(@"result is %d\n",z);

Should compile and run when linked against the Foundation framework.

Any pointer is greatly appreciated.


Gnustep-dev mailing list

Gnustep-dev mailing list

reply via email to

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