Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help - Clang can't find <objc/objc.h> on Ubuntu

385 views
Skip to first unread message

Jens Alfke

unread,
Feb 25, 2012, 12:42:00 PM2/25/12
to discuss...@gnu.org
I’m trying to get started with GNUstep development but running into problems getting the LLVM compiler and libobjc2 set up correctly.

My story: I’ve got some Foundation-level Cocoa code (i.e. no UI) that runs on OS X 10.7 and iOS 5, and I’d like to get it running in GNUstep on Linux. Syntactically, this code uses properties and blocks pretty heavily (but not GCD).

So I’ve installed Ubuntu 11.10 x86 inside VirtualBox on my MacBook Pro, and installed the following packages via apt-get:
* gnustep
* gnustep-devel
* llvm
* clang
* libobjc2

I can build & run a trivial app that calls NSLog (the example from the makefile tutorial.) And I’ve set up a makefile for my code, but when I try to build it I run into compiler problems.

If I just run “make”, GCC [4.6.1] barfs on the first use of the “^” character. So apparently it doesn’t have the Apple block extensions:
> Source/Header.h:19:11: error: expected identifier or ‘(’ before ‘^’ token

OK, according to instructions on the gnustep site, I can enter “make CC=clang LD=gcc” to build with Clang. But when I do this, Clang [2.9] can’t find objc.h:

> /usr/include/GNUstep/GNUstepBase/preface.h:112:11: fatal error: 'objc/objc.h' file not found
> #include <objc/objc.h>

The only copy of objc.h on my system is /usr/lib/gcc/i686-linux-gnu/4.6/include/objc/objc.h.
So apparently I either need to
(a) configure Clang to search that directory (which I’m reluctant to do because it may have GCC-specific stuff in it), or
(b) copy the objc/ header directory into Clang’s header search path (where?), or
(c) reconfigure libobjc2 to understand that I have Clang installed and put its headers in the right place

I’m not sure which of these is appropriate. Actually I’m confused because it sounds from what I’ve read (i.e. the libobjc2 1.6 announcement) as though libobjc2 has Clang/LLVM specific functionality, so I expected that the two would play nicely together if I installed both, without need for further customization. But I’m fairly clueless about Linux and apt-get so I may just have done something wrong…

Thanks!

—Jens


David Chisnall

unread,
Feb 25, 2012, 12:45:10 PM2/25/12
to Jens Alfke, discuss...@gnu.org
On 25 Feb 2012, at 17:42, Jens Alfke wrote:

> * libobjc2

Please be aware that the package called libobjc2 in Debian / Ubuntu is not libobjc2. Debian people seem to like giving packages random names.

The easiest thing to do is install libobjc2 from svn. I don't know what the Debian packages are built against, but hopefully they should Just Work™ with it.

David

--
This email complies with ISO 3103

Niels Grewe

unread,
Feb 25, 2012, 12:48:33 PM2/25/12
to discuss...@gnu.org
Am 25.02.2012 18:45, schrieb David Chisnall:
> On 25 Feb 2012, at 17:42, Jens Alfke wrote:
>
>> * libobjc2
>
> Please be aware that the package called libobjc2 in Debian / Ubuntu is not libobjc2. Debian people seem to like giving packages random names.

Well, not completely random. The package names are suffixed with the
soname version. So if they ever package the GNUstep runtime, they'd ship
it as libobjc4. (But yes, it's a pretty annoying policy)

Cheers,

Niels

Jens Alfke

unread,
Feb 25, 2012, 1:01:59 PM2/25/12
to Niels Grewe, discuss...@gnu.org

On Feb 25, 2012, at 9:48 AM, Niels Grewe wrote:

Please be aware that the package called libobjc2 in Debian / Ubuntu is not libobjc2.  Debian people seem to like giving packages random names.  

Well, not completely random. The package names are suffixed with the
soname version. So if they ever package the GNUstep runtime, they'd ship
it as libobjc4. (But yes, it's a pretty annoying policy)

Ah. Thanks, guys! I had already noticed there was a “libobjc3” and wondered if that was an even newer hotness :)

This might be worth calling out in the installation instructions at gnustep.org. In general, I didn’t have an easy time tracking down all the info there; it’s scattered between the static site and the wiki, and there are some obsolete bits, like a link to a seven-year-old blog post about installing GNUstep on Ubuntu.

—Jens

Thomas Davie

unread,
Feb 25, 2012, 1:03:44 PM2/25/12
to Jens Alfke, discuss...@gnu.org
Hi Jens,

I've recently done a complete build of everything up to and including having a working foundation, with blocks support on Ubuntu. I didn't use the packages for most of this stuff as I found similar issues to you. Here's what I did to get to a working setup:

sudo apt-get install subversion
sudo apt-get install g++
sudo apt-get install gobjc
sudo apt-get install vim
sudo apt-get install curl
sudo apt-get install libffi-dev
sudo apt-get install libxml2-dev
sudo apt-get install libicu-dev
sudo apt-get install libgnutls-dev
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../../
mkdir build
cd build
../llvm/configure --enable-optimized
make
sudo make install
cd ../
curl http://www.openssl.org/source/openssl-1.0.1-beta3.tar.gz > openssl-1.0.1-beta3.tar.gz # Ignore the bit about openssl if you don't need a recent one, I needed more recent than ubuntu's package manager provides
tar xvfz openssl-1.0.1-beta3.tar.gz
cd openssl-1.0.1-beta3
./config
make
sudo make install
cd ..
svn co http://svn.gna.org/svn/gnustep/tools/make/trunk/ gnustep-make
svn co http://svn.gna.org/svn/gnustep/libs/base/trunk/ gnustep-base
svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/1.6/ libobjc2
cd gnustep-make
./configure --prefix=/usr/GNUstep --enable-native-objc-exceptions --with-layout=gnustep --with-config-file=/usr/GNUstep/Local/Configuration/GNUstep.conf
make
sudo make install
vim ~/.bashrc # Add . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
exit # And reopen shell
./configure --with-openssl-include=/usr/local/ssl/include --with-openssl-library=/usr/local/ssl/lib/ --enable-libffi --with-default-config=/usr/GNUstep/Local/Configuration/GNUstep.conf
make
sudo -E make install
cd ../libobjc2
export CC=clang
make
sudo -E make install
cd ../gnustep-make
./configure --prefix=/usr/GNUstep --enable-native-objc-exceptions --with-layout=gnustep --with-config-file=/usr/GNUstep/Local/Configuration/GNUstep.conf
sudo make install
cd ../gnustep-base
make clean
./configure --with-openssl-include=/usr/local/ssl/include --with-openssl-library=/usr/local/ssl/lib/ --enable-libffi --with-default-config=/usr/GNUstep/Local/Configuration/GNUstep.conf
make
sudo -E make install

You should now have a working GNUstep Foundation :)

Hope that helps

Bob

On 25 Feb 2012, at 17:42, Jens Alfke wrote:

> _______________________________________________
> Discuss-gnustep mailing list
> Discuss...@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep


Thomas Davie

unread,
Feb 25, 2012, 1:10:10 PM2/25/12
to Thomas Davie, discuss...@gnu.org
I forgot to mention – the one thing that doesn't work in this setup, is gdb – It really doesn't like interacting with the modern runtime, and will regularly bomb at the most trivial of things. I've made various attempts at making lldb build in this process, but generally ended up with compile failures while building llvm, if you come up with a good solution, I'd love to hear it.

Bob

Jens Alfke

unread,
Feb 25, 2012, 1:25:40 PM2/25/12
to David Chisnall, discuss...@gnu.org

On Feb 25, 2012, at 9:45 AM, David Chisnall wrote:

The easiest thing to do is install libobjc2 from svn.  I don't know what the Debian packages are built against, but hopefully they should Just Work™ with it.

OK, done; I found I had to tell make to build it with Clang not gcc or I got compile errors, but that makes sense.

At the end of the build process it prints a message:

Please remember to reconfigure gnustep-make if you want it to
use the newly installed libobjc2 rather than any prior version.

Sounds reasonable, but how do I “reconfigure gnustep-make”? I installed gnustep from apt-get so I have no idea how to recompile or even locate individual components…

—Jens

Thomas Davie

unread,
Feb 25, 2012, 1:29:37 PM2/25/12
to Jens Alfke, discuss...@gnu.org
See my earlier email on the subject.

Bob

David Chisnall

unread,
Feb 25, 2012, 1:35:16 PM2/25/12
to Thomas Davie, discuss...@gnu.org
Should be able to install libobjc2 without installing GNUstep Make first. In this case, reconfiguring GNUstep Make is not required.

David


-- Sent from my Cray X1

Jens Alfke

unread,
Feb 25, 2012, 1:52:22 PM2/25/12
to Thomas Davie, discuss...@gnu.org

On Feb 25, 2012, at 10:29 AM, Thomas Davie wrote:

See my earlier email on the subject.

I did, thanks, but I’m trying first to see if I can get things working the easy way, before diving into the long list of manual instructions…


On Feb 25, 2012, at 10:35 AM, David Chisnall wrote:

Should be able to install libobjc2 without installing GNUstep Make first.  In this case, reconfiguring GNUstep Make is not required.

OK; I used apt-get to uninstall gnustep-devel, then re-installed it. Doesn’t appear to make any difference; I get exactly the same errors. Make still defaults to GCC, and if I override it to use Clang, I get a compiler error "error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them”.

—Jens

Ivan Vučica

unread,
Feb 25, 2012, 3:49:26 PM2/25/12
to Jens Alfke, discuss...@gnu.org
Aside from what everyone posted, see also this old post of mine in case you want to get everything to work with stock Debian packages:

I last tried this... back in December 2010, obviously.

It would be a really good idea, however, to build as much stuff from source if you want to do GNUstep development.
--
Ivan Vučica - iv...@vucica.net


Amr Aboelela

unread,
Feb 26, 2012, 2:52:04 AM2/26/12
to discuss...@gnu.org
3. Make link to objc directory:

        $ locate objc.h

/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/include/objc/objc.h

- Then:
        /usr/local/include$ sudo ln -s /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/include/objc/ objc
Info about Islam: http://wikiz.info/islam
Latest news on twitter: http://www.twitter.com/zagel
Contribute in a wiki: http://wikiz.info


David Chisnall

unread,
Feb 26, 2012, 6:20:17 AM2/26/12
to Amr Aboelela, discuss...@gnu.org
On 26 Feb 2012, at 07:52, Amr Aboelela wrote:

> 3. Make link to objc directory:
>
> $ locate objc.h
>
> /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/include/objc/objc.h

This is the GCC runtime's objc.h. You almost certainly want to be using the GNUstep runtime's version instead. This will install in /usr/locale/include/objc by default, or in your GNUstep headers location if GNUstep Make is installed.

David

-- Sent from my Difference Engine




Ivan Vučica

unread,
Feb 26, 2012, 11:28:11 AM2/26/12
to David Chisnall, discuss...@gnu.org
On Sun, Feb 26, 2012 at 12:20, David Chisnall <ther...@sucs.org> wrote:

This is the GCC runtime's objc.h.  You almost certainly want to be using the GNUstep runtime's version instead.  This will install in /usr/locale/include/objc by default, or in your GNUstep headers location if GNUstep Make is installed.


From what I gathered,  OP wants to start coding by using as many packages from Ubuntu as possible, and neither Debian nor Ubuntu ship with GNUstep's runtime as opposed to GCC runtime.

GNUstep runtime is awesome, and I use it. But if OP has different goals (like I used to have), then he might be get away with the GCC runtime.

With that said, people writing new code and people porting code over to GNUstep should definitely avoid the prepackaged binaries of GNUstep (except on Windows) and should instead install from source. At that point, building another runtime (such as the GNUstep runtime) when everything else is already being built is practically the only sane option.

Especially if the runtime being replaced is from GCC 4.5 or older.
 
0 new messages