7

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

James Raitsev
  • 87,465
  • 141
  • 322
  • 462
  • 1
    Just a heads up: you cannot compile code that uses Apple's Cocoa classes. I recommend reading this post: [Starting iPhone app development in Linux?](http://stackoverflow.com/questions/276907/starting-iphone-app-development-in-linux) – Jeremy Dec 21 '11 at 17:21

2 Answers2

9

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++
N_A
  • 19,627
  • 4
  • 49
  • 97
4
gcc -x objective-c file.m -o out

Google is your friend

Manlio
  • 10,538
  • 9
  • 47
  • 77