5

I have installed clang on my Raspberry Pi. How can I compile a .m file (Objective C) through the terminal?

Let's say I called it bob.m and I want the output file to be called bob and I'm already in the correct directory, what is the exact command?

fouric
  • 1,809
  • 4
  • 18
  • 26
user1628
  • 161
  • 1
  • 3

2 Answers2

5

To compile Object-C:

clang <the file name, i.e. bob.m> -o <the target name, i.e. bob>

so

clang bob.m -o bob

Foundation is part of GNUStep which will have to be installed.

sudo apt-get install gnustep

You will then need to tell clang about it.

clang `gnustep-config --objc-flags` bob.m -o bob  `gnustep-config --base-libs`
mlk
  • 218
  • 2
  • 8
2

You need to instal the objective c run time libraries as well as OpenStep/gnuStep if you want to import foundation.h. Objective-c does not come bundled with clang.

Apparently you can get gnustep with apt-get:

sudo apt-get install gnustep

Once that is installed, you should be able to compile against foundation.h

JoshRagem
  • 171
  • 6