sschimper
sschimper

Reputation: 93

GNUstep - fatal error: 'objc/objc.h' file not found on Ubuntu 20.04

I have the following problem:

I am on Ubuntu 20.04 and I am trying to set up GNUstep which is required for certain source binaries I want to build

(for the sake of completion, the program I want to build is called Advanced Rendering Toollḱit, information can be found here: https://cgg.mff.cuni.cz/ART/).

When building with the clang-9 compiler, after invoking the make command, I receive this error message:

fatal error: 'objc/objc.h' file not found

I should mention that I am still fairly new to Linux in general. What I did was installing GNUstep via

sudo apt-get install gnustep gnustep-devel

as advised on the website (http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux). It resulted in receiving the mentioned error.

/usr/include/GNUstep/Foundation/Foundation.h:31:9: fatal error: 'objc/objc.h' file not found

The next thing I tried was to download the provided configuration scripts from the same webpage and execute them. When I did, I received the following feedback:

checking whether objc really works... no. I don't seem to be able to use your Objective-C compiler to produce working binaries! Please check your Objective-C compiler installation. If you are using gcc-3.x make sure that your compiler's libgcc_s and libobjc can be found by the dynamic linker - usually that requires you to play with LD_LIBRARY_PATH or /etc/ld.so.conf. Please refer to your compiler installation instructions for more help. configure: error: The Objective-C compiler does not work or is not installed properly.

Maybe I am getting something wrong, however, my whole intention of installing GNUstep is to make Objective-C programming possible on a non-Apple machine. Therefore I do not understand why it is complaining about a non-working Objective-C compiler (by the way, I end up with the same result when using gcc and g++ as compilers).

I did do some research and I came across some StackOverflow posts, suggesting me to install libobjc2, but I suspect this to be depreciated with Ubuntu 20.04.

I honestly don't know what's wrong and I highly appreciate a little push in the right direction! Many thanks in advance for helping me!

Upvotes: 1

Views: 1276

Answers (2)

ceztko
ceztko

Reputation: 15207

As people are pointing, if you want to use clang to compile objective C programs in Ubuntu you have to install libobjc2 (mainstream project here) but it's currently not packaged in Ubuntu. It's possible that there was a package with the same or similar name, as you found out, but that was a different thing. This manual installation worked for me:

wget https://github.com/gnustep/libobjc2/archive/v2.0.tar.gz
tar xvzf v2.0.tar.gz
cd libobjc2-2.0
mkdir build
cd build
export CC=`which clang`
export CXX=`which clang++`
cmake ..
make
sudo make install

Upvotes: 1

sschimper
sschimper

Reputation: 93

Although I cannot tell what exactly the bug was in my case, I got some external help and together we came up with a solution that worked for me. For debugging purposes, we created a test user account in my Ubuntu environment and repeated the whole process. It worked flawlessly. We concluded that something must have been wrong locally with regard to my user account. I am sure there was something wrong with my environment variables, although I failed to clearly identify the bug (I am a Linux beginner). I chose the easy way out, backed up important files, deleted and re-created my root user account and then it worked. I hope, this may help any other who has the same problem. @skaak, thank you for your help and suggestions!

Upvotes: 1

Related Questions