1

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!

sschimper
  • 83
  • 2
  • 8
  • The problem seems to be compiler as the error hints. If you are just interested in Objective-C in non-Apple then check out ObjFW ... GNUstep is a really tough one to set up and get working. But both of these (GNUstep and ObjFW) are more academic than really a type of replacement for Apple FWIW. – skaak Jul 31 '20 at 13:03
  • On Arch Linux you need gcc-objc so I presume something like ```sudo apt-get install gcc-objc``` will work in your environment? – skaak Jul 31 '20 at 13:10
  • Hi @skaak, thanks a lot for the input. There seems to be a package on Ubuntu called "gobjc" resp. "gobjc++". I intalled both and tired again, the error remains. (Background: the tool I want to build is for usage in research and it was developed mainly on Apple-machines, that's why GNUstep is a dependecy. It is for my university thesis. Buying an Apple computer or hackintosh is not really an option for me ... so GNUstep it is :). Although, as a beginner it keeps me quite busy) – sschimper Jul 31 '20 at 13:36
  • Hi - yes I looked at that tool. FWIW a year or two ago I got Objective-C working on Arch no problem, but I could never get GNUstep compiling. I just wanted to experiment and ObjFW was really nice for that, but I suppose it is not worth much for what you want. Anyhow, if what I did helps, it is that it was not that difficult to get Objective-C going under Linux. I got both gnu and llvm working easily but did not keep notes and only used standard Arch packages. I think just make sure you have properly installed your full development environment in your Linux and try again. – skaak Jul 31 '20 at 13:45
  • FWIW I got it compiled just now. Just downloaded ART into my Arch Linux ... had to install cmake and run ```cmake CMakeLists.txt``` and then ```make``` in the install root dir. – skaak Jul 31 '20 at 14:10
  • From the output I gather that it used GNU 10.1.0 compiler and that it linked to ```libgnustep-base.so```. Was piece of cake. I think you need to just install the right packages. First - full development environment with make and all. Then cmake and whatever package contains GNUstep-base (seems only requirement) and you should be able to get it working – skaak Jul 31 '20 at 14:13
  • Hi @saak, thanks again for sharing your insight with me. I found a solution for me and I will write a separate post for it during the next minutes (turned out it was something local. I think it is a common experience for Windows users that recently switched to Linux, to find out that Linux lets you easily mess with files you shouldn't mess with :) ) – sschimper Jul 31 '20 at 15:28

2 Answers2

1

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!

sschimper
  • 83
  • 2
  • 8
  • Great, I myself was able to install it by compiling from source as explained here: http://wiki.gnustep.org/index.php/Building_GNUstep_under_Debian_FreeBSD – MathNerd Sep 26 '20 at 19:28
  • @MathNerd thanks, I visited that page too. I remembered that I had some issues following the instructions, but I don't remember what they were. I am still fairly new to Linux/Unix in general :) – sschimper Nov 13 '20 at 09:48
1

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
ceztko
  • 14,736
  • 5
  • 58
  • 73