[Compile/Linking problem] unable to compile simple HelloWorld GUI program

Discussion in 'iOS Development' started by ipwnedmyphone, Feb 4, 2009.

  1. ipwnedmyphone

    ipwnedmyphone New Member

    Joined:
    Dec 3, 2008
    Messages:
    6
    Likes Received:
    0
    [solved

    Please Register or Log in to view images

    ][Compile/Linking problem] unable to compile simple HelloWorld GUI program


    Hi Guys,

    I have just set out to explore the world of iphone app development.....in windows
    After a great deal effort (and frustration), i was finally able to install the toolchain and compile the simple console HelloWorld application.
    Gaining confidence by its success, i ventured a little deeper and tried to compile the GUI version of the HelloWorld example.

    This is where the problems began. I get this whole bunch of errors regarding libobjc:

    Code:
    /usr/local/bin/arm-apple-darwin9-ld: Undefined symbols:
    _objc_msgSendSuper2
    _OBJC_EHTYPE_id referenced from Foundation expected to be defined in libobjc
    _OSAtomicCompareAndSwapPtr referenced from Foundation expected to be defined in libSystem
    _OSAtomicCompareAndSwapPtrBarrier referenced from Foundation expected to be defined in libSystem
    ___objc_personality_v0 referenced from Foundation expected to be defined in libobjc
    _flsl referenced from Foundation expected to be defined in libSystem
    _objc_begin_catch referenced from Foundation expected to be defined in libobjc
    _objc_end_catch referenced from Foundation expected to be defined in libobjc
    _objc_exception_rethrow referenced from Foundation expected to be defined in libobjc
    _objc_getProtocol referenced from Foundation expected to be defined in libobjc
    _objc_msgSendSuper2 referenced from Foundation expected to be defined in libobjc
    
    _protocol_conformsToProtocol referenced from Foundation expected to be defined in libobjc
    _protocol_getMethodDescription referenced from Foundation expected to be defined in libobjc
    _protocol_getName referenced from Foundation expected to be defined in libobjc
    _removefile referenced from Foundation expected to be defined in libSystem
    _removefile_state_alloc referenced from Foundation expected to be defined in libSystem
    _removefile_state_free referenced from Foundation expected to be defined in libSystem
    _removefile_state_get referenced from Foundation expected to be defined in libSystem
    _removefile_state_set referenced from Foundation expected to be defined in libSystem
    _objc_copyStruct referenced from UIKit expected to be defined in libobjc
    _objc_getProperty referenced from UIKit expected to be defined in libobjc
    _objc_msgSendSuper2_stret referenced from UIKit expected to be defined in libobjc
    _objc_setProperty referenced from UIKit expected to be defined in libobjc
    _sel_isEqual referenced from UIKit expected to be defined in libobjc
    ___memmove_chk referenced from CoreFoundation expected to be defined in libSystem
    _bootstrap_look_up2 referenced from CoreFoundation expected to be defined in libSystem
    _bootstrap_register2 referenced from CoreFoundation expected to be defined in libSystem
    _class_replaceMethod referenced from CoreFoundation expected to be defined in libobjc
    _objc_ehtype_vtable referenced from CoreFoundation expected to be defined in libobjc
    _objc_setExceptionMatcher referenced from CoreFoundation expected to be defined in libobjc
    _objc_setExceptionPreprocessor referenced from CoreFoundation expected to be defined in libobjc
    _objc_setUncaughtExceptionHandler referenced from CoreFoundation expected to be defined in libobjc
    _protocol_copyMethodDescriptionList referenced from CoreFoundation expected to be defined in libobjc
    _vproc_swap_integer referenced from CoreFoundation expected to be defined in libSystem
    collect2: ld returned 1 exit status
    make: *** [HelloWorld] Error 1
    
    Could someone please help me with this?

    Please Register or Log in to view images


    I used the toolchain guide given in this pdf.

    Ive searched a lot but not been able to find any solution. It looks like a linking problem, but i cannot understand what needs to be done.

    Thanks,
    Sid
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    You aren't linking to your libraries directory, usually /usr/lib
  3. ipwnedmyphone

    ipwnedmyphone New Member

    Joined:
    Dec 3, 2008
    Messages:
    6
    Likes Received:
    0
    Hi Skylar,

    Thanks for quick reply.

    I dont have any 'lib' folder in /usr

    This is how my makefile looks:

    Code:
    CC=arm-apple-darwin9-gcc -fobjc-abi-version=2
    LD=$(CC)
    LDFLAGS=	-lobjc \
    				-framework UIKit \
    				-framework Foundation \
    				-framework CoreFoundation \
    				-framework CoreGraphics \
    				-L"/usr/local/iphone-sysroot/usr/lib" \
    				-F"/usr/local/iphone-sysroot/System/Library/Frameworks" \
    				-F"/usr/local/iphone-sysroot/System/Library/PrivateFrameworks" \
    				-bind_at_load \
    				-multiply_defined suppress
    CFLAGS= -I"/var/include" \
            -I"/usr/local/iphone-sysroot/usr/include" \
    		-I"/usr/local/include" \
    		-I"/usr/local/lib/gcc/arm-apple-darwin9/4.2.1/include"
    App=Window
    
    all:	$(App)
    
    $(App):	main.o WindowApp.o
    	$(LD) $(LDFLAGS) -o $@ $^
    		ldid -S $(App)
    
    
    %.o:	%.m
    		$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    
    clean:
    		rm -f *.o $(App)
    
    The folders mentioned in LDFLAGS exist. Is there something i am missing here or maybe something that i need to check?

    Thanks,
    Sid
    ------------------double post merged------------------
    ok, looks like my libobjc.dylib and libsystem.dylib were messed up. After correcting them i have narrowed down to two errors:

    Code:
    ___floatdidf referenced from Foundation expected to be defined in libgcc
    ___floatdisf referenced from Foundation expected to be defined in libgcc
    collect2: ld returned 1 exit status
    make: *** [Window] Error 1
    
    Any pointers on this??
    ------------------double post merged------------------
    Hurray!!!!

    I am finally able to compile my iphone app

    Please Register or Log in to view images


    I corrected all the dylib files and rebuilt the toolchain.

    As always, the solution to each problem leads to another (problem, not solution)

    I was not able to run the app on my phone, since i had not codesigned it. For some inexplicable reason, i was not able to install ldid in my cygwin installation, as i get a strange 'crt0.o: no such file or directory' error. I dont know where i am supossed to find this file at....

    Anyway, I think ill install ldid from cydia and sign the code from the phone itself.

    However, my phone is 2.2 and the toolchain is 2.0; will there be any problem in ldid in this scenario?

Share This Page