NSLog Error: Can't Find "NXConstantString"?

I finally got GNUstep working (on windows) and it compiles and works fine. However, when I try to use NSLog, I get the following error:

$ gcc -o hello hello.m -I /GNUstep/System/Library/Headers \ > -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base hello.m: In function 'main': hello.m:4:5: error: cannot find interface declaration for 'NXConstantString' 

My source code:

 #import <Foundation/Foundation.h> int main(void) { NSLog(@"hello world"); } 
+4
source share
3 answers

It -

 NSLog(@"hello world"); 

not

  NSlog(@"hello world"); // 'l' should be upper case in NSLog 

Try it -

 gcc -o hello hello.m -I /usr/lib/GNUstep/System/Library/Headers \ -L /usr/lib/GNUstep/System/Library/Libraries/ -lgnustep-base \ -fconstant-string-class=NSConstantString 

How to compile objective c programs using gcc

+11
source

Try the following:

 $gcc -o hello hello.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString 

Note

 -fconstant-string-class=NSConstantString 

without this command, it treats persistent string objects as a type of the NXConstantString class.


For start:

 $./hello.m or whatever your objective-c code file name. 
+2
source

it's very easy to put a space between -lgnustep-base and -fconstant-class=NSConstantString

Incorrect: -lgnustep-base-fconstant-class=NSConstantString

Correct path: -lgnustep-base -fconstant-class=NSConstantString

0
source

Source: https://habr.com/ru/post/1339445/


All Articles