How to compile Objective C code in ubuntu

I am starting to program Iphone. I am trying to compile (ubuntu).

#import <Foundation/Foundation.h>

int main (void)
 {
  NSLog (@"Executing");
  return 0;
 }

I compiled it but got the following error

   subhash@subhash-Lenovo-G570:~/grit/iphone/mac$ gcc -lgnustep-base -lpthread -lob
  jc -lm -I/usr/local/include/GNUstep -I/usr/include/GNUstep -fconstant-string-cla
  ss=NSConstantString hello.m -o hello
  In file included from /usr/include/GNUstep/Foundation/NSClassDescription.h:30:0,
                  from /usr/include/GNUstep/Foundation/Foundation.h:50, 
                  from hello.m:1:
  /usr/include/GNUstep/Foundation/NSException.h:42:2: error: #error The current se
  tting for native-objc-exceptions does not match that of gnustep-base ... please 
  correct this.

i followed http://ubuntuforums.org/showthread.php?p=5593608 as a reference.

I commented on the #error NSException.h directive and the problem is resolved. Now I get a new error.

/tmp/ccQlI9wJ.o: In function `main':
        hello.m:(.text+0x11): undefined reference to `NSLog'
        /tmp/ccQlI9wJ.o: In function `__objc_gnu_init':
        hello.m:(.text+0x2a): undefined reference to `__objc_exec_class'
        /tmp/ccQlI9wJ.o:(.data+0x40): undefined reference to `__objc_class_name_NSConsta
        ntString'
        collect2: ld returned 1 exit status
+5
source share
2 answers

In Compile Objective-C Programs using gcc , the following exists

Also note that if you did not specify -D_NATIVE_OBJC_EXCEPTIONS, you may encounter the following error:

/usr/include/GNUstep/Foundation/NSException.h:42:2: error: #error The
current setting for native-objc-exceptions does not match that of
gnustep-base ... please correct this.

, , -D_NATIVE_OBJC_EXCEPTIONS . - , .

, shalki . , , , , , Objective-C Linux - , , , ,

`gnustep-config --objc-flags`

gcc.

gcc `gnustep-config --objc-flags` hello.m -o hello -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -lgnustep-base

. gnustep-config --objc-flags

-MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -D_REENTRANT -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fgnu-runtime -fconstant-string-class=NSConstantString -I. -I/home/faheem/GNUstep/Library/Headers -I/usr/local/include/GNUstep -I/usr/include/GNUstep

Yowza. , -D_NATIVE_OBJC_EXCEPTIONS, . Debian. Debian/Ubuntu. .

+3

All Articles