Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile objc code on Linux?

Assuming you have your .h and .m ready on a Linux server, which command would you issue to GCC to have it compiled?

like image 907
James Raitsev Avatar asked Dec 21 '11 17:12

James Raitsev


People also ask

How do I run Objective-C on Linux?

The gcc Objective-C support can be installed on Linux simply by installing the gcc-objc package which is available with all Linux distributions. There are, however, two different paths to installing GNUstep.

What is GCC OBJC?

0 GNU Compiler Collection. This is a GNU package. GCC is the GNU Compiler Collection. It provides compiler front-ends for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and Go.

Does Objective-C compile to C?

Objective-C compiles into machine code. Remember that the language (Objective-C, C, C++) only defines the rules to correctly write code. The compiler checks to see if your code is correct and compiles it, i.e., translates it into executable code. Also, don't confuse Objective-C language, and the Objective-C runtime.


2 Answers

gcc -x objective-c file.m -o out

Google is your friend

like image 41
Manlio Avatar answered Oct 13 '22 06:10

Manlio


The relevant parts:

gcc -c -Wno-import List.m

gcc -o prog -Wno-import List.o main.o -lobjc

. . . make sure that the Objective-C library and header files (objc/Object.h) were installed when gcc was built.

Note that when linking Objective-C with gcc, you need to specify the Objective-C library by using the -lobjc switch.

See this link for more information.

Additional link with possible solution to the missing compiler issue:

Try installing either gobjc++ or gobjc

sudo apt-get install gobjc++
like image 99
N_A Avatar answered Oct 13 '22 05:10

N_A