Chandan
Chandan

Reputation: 404

Objective C Compilation error in Ubuntu

I am very new to Objective C. I just started with. I have downloaded objective C package and done all the steps exactly as in "http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux". I compiled the code also mentioned in the link. That works fine. However I have written very basic program just to print a message but I am getting compilation error.

/tmp/Chandan-59bf66.o: In function main': /home/chandan/Documents/Chandan.m:6: undefined reference toNSLog' clang: error: linker command failed with exit code 1 (use -v to see invocation).

Here is my code

#import <Foundation/Foundation.h>

int main(int argc, const char *argv[]){

@autoreleasepool{
NSLog(@"Hello World");
}
return 0;
}

Please guide me. Thanks in advance

Upvotes: 0

Views: 71

Answers (1)

ljk321
ljk321

Reputation: 16770

I'm thinking you need more flags for compiler. Here's mine:

clang   $1\
-MMD \
-MP \
-DGNUSTEP \
-DGNUSTEP_BASE_LIBRARY=1 \
-DGNU_RUNTIME=1 \
-DGNUSTEP_BASE_LIBRARY=1 \
-fno-strict-aliasing \
-fexceptions \
-fobjc-exceptions \
-D_NATIVE_OBJC_EXCEPTIONS \
-pthread \
-fPIC \
-Wall \
-DGSWARN \
-DGSDIAGNOSE \
-Wno-import \
-g \
-O2 \
-fgnu-runtime \
-fblocks \
-fobjc-nonfragile-abi \
-fconstant-string-class=NSConstantString \
-I . \
-I /GNUstep/System/Library/Headers/ \
-L /GNUstep/System/Library/Libraries/ \
-lobjc \
-lgnustep-base \
-lgnustep-gui \
-ldispatch

Upvotes: 1

Related Questions