Problem building lottery source


#1

I used to build for mac using Qt framework and now starting to use Cocoa an Obj-C. I have got strange error messages pointing to the Foundation Library so the fail must come from anywhere but not the code because is coming from the book and no faults on compiling. My version of Xcode is 3.2.2 and it did no created a lottery.m but a main.c on resources folder. Building without changing the extension of the file generate thousand of “expected identifier or ‘(’ before ‘@’ token” in NSObjCRuntime.h, NSValueTransformer.h and many more. Renaming the main source file extension to ‘.m’ it generates five fails, a collect 2 with those details:

Undefined symbols:
OBJC_CLASS_NSAutoreleasePool", referenced from: objc-class-ref-to-NSAutoreleasePool in lottery.o "_objc_msgSend", referenced from: _main in lottery.o _main in lottery.o _main in lottery.o _main in lottery.o (maybe you meant: l_objc_msgSend_fixup_objectAtIndex_, l_objc_msgSend_fixup_addObject_ , l_objc_msgSend_fixup_alloc ) "_objc_msgSend_fixup", referenced from: l_objc_msgSend_fixup_alloc in lottery.o l_objc_msgSend_fixup_addObject_ in lottery.o l_objc_msgSend_fixup_objectAtIndex_ in lottery.o (maybe you meant: l_objc_msgSend_fixup_objectAtIndex_, l_objc_msgSend_fixup_addObject_ , l_objc_msgSend_fixup_alloc ) "_OBJC_CLASS__NSNumber”, referenced from:
objc-class-ref-to-NSNumber in lottery.o
"_NSLog", referenced from:
_main in lottery.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I've done a few search by myself and found something but not the solution and maybe will be a compiler or build setup someone probably had this before.

Thanks,


#2

just to easy, the problem is in the creation of the instance and in it s initialization

#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool; // ok
pool = [NSAutoreleasePool alloc]; // 2 faults
[pool init]; // 1 fault

return 0;

}


#3

It should be something inside the library because any class of this library being initialized or allocated generate thoose fails (changed many things in garbage collection and GCC options also without results ), actually Im going to wait a new machine with everything up to date ( could not update this one for several reasons ) and see what hapens.


#4

That’s it, is what slaves of the antipattern copy-paste become but who wins in this time consuming world. I only got a real error message building in the console and downed that non-ASCII charachters passed even after cleaning on a plain text editor. Well, next time to use pure ASCII editor and check in the hex mode or even type as said in the advice, cc-cv is not programming :slight_smile:.


#5

I will fix a few mistakes from last reply: it build well in terminal but not inside the Xcode even after thoose character faults fixed, not an antipattern slave ( actually OO is evrything to save time ) but bad manner’s to save time …

cc -framework Foundation -o loto-app lottery.m

maybe a path somewhere … ?