Compilation error clang (undefined link to objc_autoreleasepoolpush)

So, I installed Ubuntu and clang3.0 and a simple .m program:

#include <Foundation/Foundation.h>
int main()
{
        @autoreleasepool{
            NSLog(@"Hi");
        }

        return 0;
}

and I am trying to compile it like this:

clang first.m -I /usr/include/GNUstep/ -lgnustep-base -fconstant-string-class=NSConstantString -objc

and i get

undefined reference to objc_autoreleasePoolPush
undefined reference to objc_autoreleasePoolPop

so I searched googled a bit and installed objc2 and tried:

clang first.m -I /usr/include/GNUstep/ -lgnustep-base -fconstant-string-class=NSConstantString -objc2

but nothing changes. Maybe someone solved the same problem?

+5
source share
3 answers

If libobjc2 is installed on my Ubuntu system, a copy of your first.m files is compiled for me using this line:

clang first.m `gnustep-config --objc-flags` `gnustep-config --objc-libs` \
-I /usr/include/GNUstep/ -lgnustep-base

but maybe it's just a typo at the end of your command lines?

-objc -objc2 clang bjc bjc2 . -lobj? , obj Objective-C. libobjc2, - libobjc.so.x.y. -lobjc, , . , .

0

, GNUstep, OS X -fobjc-arc , ARC.

0

GNUmakefile?

, .

http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/node2.html

clang first.m -c -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY = 1 -DGNU_GUI_LIBRARY = 1 -DGNU_RUNTIME = 1 -DGNUSTEP_BASE_LIBRARY = 1 -fobjc-runtime = gnustep-1.7 -fno-strict-aliasing -fexceptions -fobjc- -D_NATIVE_OBJC_EXCEPTIONS -fobjc-nonfragile-abi -D_NONFRAGILE_ABI -pthread -fPIC -DDEBUG -fno-omit-frame-pointer -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -fgnu-runtime -fconstant-string-class= NSConstantString - . -I/usr/local/include -o obj/first.obj/first.m.o

clang -rdynamic -pthread -shared-libgcc -fexceptions -fobjc-nonfragile-abi -fgnu-runtime -o obj/first./obj/first.obj/first.mo -L/usr/local/lib -lgnustep -base -lobjc -lm

, GNUstep make.

0

All Articles