objective c - Link with GNUstep on Ubuntu 14.04, 64 bit -


i attempting compile simple application references gnustep classes, gnustep on ubuntu 14.04, 64 bit, machine:

#import <foundation/foundation.h> #import <cocoa/cocoa.h>  int main(int argc, char **argv) {     nsstring *besttype = [[nspasteboard generalpasteboard]                           availabletypefromarray: nil];     nslog(@"best type: %@", besttype);     return 0; } 

here compile , link flags (some of may overkill):

cflags=`gnustep-config --objc-flags` -std=gnu99 ldflags=`gnustep-config --base-libs` -lgnustep-base -lobjc -lm -lglut -lglu -lgl 

before compilation ran script:

/usr/share/gnustep/makefiles/gnustep.sh 

and here output 'make -n'

gcc main.m `gnustep-config --objc-flags` -std=gnu99 -l. `gnustep-config --base-libs` -lgnustep-base -lobjc -lm -lglut -lglu -lgl -o tester 

but when linking, cocoa classes seem not pulled in, , undefined reference error:

/tmp/ccnyxboh.o:(.data.rel+0x8): undefined reference `__objc_class_name_nspasteboard' 

if remove references cocoa classes in main.m, app compiles without error.

the reason why can't find class definition nspasteboard because it's in gnustep-config --gui-libs options - i.e. symbol in gui library of gnustep, not in base library of gnustep. solution change ldflags line to:

ldflags=`gnustep-config --gui-libs` -lglut -lglu -lgl 

you shouldn't need double-specify -lgnustep-base -lobjc -lm - they're part of both --base-libs , --gui-libs.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -