salah1979 / iphone-dev

Automatically exported from code.google.com/p/iphone-dev
0 stars 0 forks source link

Undefined framework symbols #154

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Successfully build toolchain against MacOSX10.4u SDK and iPod Touch
2.0.2 firmware and filesystem, following issue 141 and patch provided in
issue 145.

2. Compile and link following code:

    #import <UIKit/UIKit.h>
    int main (int argc, char** argv)
    {
      NSAutoreleasePool* autoreleasePool =
        [[NSAutoreleasePool alloc]  init];
      return 0;
    }

    $ /usr/local/bin/arm-apple-darwin-gcc -c main.m -o main.o
    $ /usr/local/bin/arm-apple-darwin-gcc -lobjc
          -framework CoreFoundation
          -framework Foundation
          -framework UIKit
          -o MyApp main.o

What is the expected output? What do you see instead?

I get the following error:

    /usr/local/bin/arm-apple-darwin-ld: Undefined symbols:
    .objc_class_name_NSAutoreleasePool
    collect2: ld returned 1 exit status

What version of the product are you using? On what operating system?

Toolchain built as per wiki instructions with issue 141 and issue 145.
Ubuntu 7.10 on AMD64.

Please provide any additional information below.

It basically doesn't find any of the framework symbols. A couple of months
ago, I had built the toolchain against the same iPod Touch but with an old
1.x firmware and filesystem, and everything was fine then, I could build
and run my application fine.

Original issue reported on code.google.com by eric.sel...@gmail.com on 3 Oct 2008 at 10:53

GoogleCodeExporter commented 8 years ago
I can't find something like 
/usr/local/bin/arm-apple-darwin-ld: Undefined symbols:
.objc_class_name_NSAutoreleasePool
.objc_class_name_UIApplication
.objc_class_name_UIHardware
.objc_class_name_UITextView
.objc_class_name_UIView
.objc_class_name_UIWindow

Original comment by Henry.Hu...@gmail.com on 14 Oct 2008 at 3:24

GoogleCodeExporter commented 8 years ago
Got the same problem:

-------------------------------------------------------------------------
/usr/local/bin/arm-apple-darwin-ld: Undefined symbols:
.objc_class_name_NSAutoreleasePool
.objc_class_name_UIApplication
.objc_class_name_UIHardware
.objc_class_name_UITextView
.objc_class_name_UIView
.objc_class_name_UIWindow
-------------------------------------------------------------------------

Can anyone help, please?

P.S. Makefile in attach.

Original comment by dee...@gmail.com on 22 Oct 2008 at 2:02

Attachments:

GoogleCodeExporter commented 8 years ago
Does anyone have a solution for this problem yet?
I was able to link it somehow before, but now i'm stuck again

Original comment by roy.s...@gmail.com on 20 Jan 2009 at 3:04

GoogleCodeExporter commented 8 years ago
Anyone have idea how to solve this?

Is that because the framework on iphone not compatible with this toolchain 
anymore?
I'm using firmware 2.2.1

Thanks, really need a answer

Original comment by roc.roc....@gmail.com on 8 Apr 2009 at 11:00

GoogleCodeExporter commented 8 years ago
I have the same Problem, i have tested it on 32Bit "openSUSE 10.3" and cygwin 
Windows 32Bit, both exctly the same problem.

I'm using firmware 2.2.1

Regards, Christian

Original comment by cla...@nw7.de on 21 Apr 2009 at 7:44

Attachments:

GoogleCodeExporter commented 8 years ago
I have the same problem on cygwin/XP, firmware 2.2.1 (5H11), toolchain built 
against
MacOSX10.4.Universal.pkg, using svn revisions from issue 141 and patches from 
issue 145. 

I notice that the NSAutorelease symbol is displayed when running:

$ arm-apple-darwin-nm
/usr/local/share/iphone-filesystem/System/Library/Frameworks/Foundation.framewor
k/Foundation
| grep NSAutorelease
306d1cac t +[NSAutoreleasePool addObject:]
3066f938 t +[NSAutoreleasePool allocWithZone:]
306c66ac t +[NSAutoreleasePool autoreleasePoolExists]
306d1b52 t +[NSAutoreleasePool autoreleasedObjectCount]
306d1b90 t +[NSAutoreleasePool enableFreedObjectCheck:]
306d1b66 t +[NSAutoreleasePool enableRelease:]
306d1bb8 t +[NSAutoreleasePool poolCountHighWaterMark]
306d1bf8 t +[NSAutoreleasePool poolCountHighWaterResolution]
30676fd0 t +[NSAutoreleasePool releaseAllPools]
306d1c44 t +[NSAutoreleasePool resetTotalAutoreleasedObjects]
306d1bd4 t +[NSAutoreleasePool setPoolCountHighWaterMark:]
306d1c14 t +[NSAutoreleasePool setPoolCountHighWaterResolution:]
306d1b48 t +[NSAutoreleasePool showPools]
306d1b5c t +[NSAutoreleasePool topAutoreleasePoolCount]
306d1c38 t +[NSAutoreleasePool totalAutoreleasedObjects]
306d1cb8 t -[NSAutoreleasePool addObject:]
306d1ad4 t -[NSAutoreleasePool autorelease]
306d1b2c t -[NSAutoreleasePool dealloc]
30672828 t -[NSAutoreleasePool drain]
3066f9d8 t -[NSAutoreleasePool initWithCapacity:]
3066f9c0 t -[NSAutoreleasePool init]
30677a90 t -[NSAutoreleasePool release]
306d1ad0 t -[NSAutoreleasePool retainCount]
306d1a78 t -[NSAutoreleasePool retain]
3066eb8c T _NSAutoreleaseObject
306d17c8 T _NSAutoreleasePoolCount
306d1844 T _NSAutoreleasePoolCountForObject
3866cb04 D _OBJC_CLASS_$_NSAutoreleasePool
3866caf4 d _OBJC_IVAR_$_NSAutoreleasePool._reserved
3866caf8 d _OBJC_IVAR_$_NSAutoreleasePool._reserved2
3866cafc d _OBJC_IVAR_$_NSAutoreleasePool._reserved3
3866cb00 d _OBJC_IVAR_$_NSAutoreleasePool._token
3866cb40 D _OBJC_METACLASS_$_NSAutoreleasePool
306d1774 T __NSAutoreleaseFreedObject
306d1788 T __NSAutoreleaseHighWaterLog
306d1c54 T __NSAutoreleaseNoPool
306d179c T __NSAutoreleasePoolGetRubyToken
306d17b0 T __NSAutoreleasePoolSetRubyToken
38690394 b ___NSAutoreleaseFreedObjectCheckEnabled
3869039c b ___NSAutoreleaseHighWaterMark
38690398 b ___NSAutoreleaseHighWaterResolution
3066ebfc t ___NSAutoreleaseObject
3866cd0c d ___NSAutoreleaseReleaseEnabled

although this doesn't appear to display the ".objc_class_name_*" name-mangling 
prefix
that arm-apple-darwin-ld is looking for. Is there something I'm missing here ?

NB: Issue 117 appears to be a duplicate of this issue.

Original comment by randomn...@gmail.com on 30 Apr 2009 at 10:37

GoogleCodeExporter commented 8 years ago
Sorry, should have included the LDFLAGS from my Makefile earlier:

LDFLAGS = -lobjc \
  -F/usr/local/share/iphone-filesystem/System/Library/Frameworks \
  -F/usr/local/share/iphone-filesystem/System/Library/PrivateFrameworks \
  -framework Foundation \
  -framework UIKit \
  -framework CoreGraphics

which, looking at the command-lines generated in procmon.exe, runs:

C:\cygwin\usr\local\bin\arm-apple-darwin-gcc.exe -lobjc
-F/usr/local/share/iphone-filesystem/System/Library/Frameworks
-F/usr/local/share/iphone-filesystem/System/Library/PrivateFrameworks -framework
Foundation -framework UIKit -framework CoreGraphics -o Example Example.o

[...]

C:\cygwin\usr\local\libexec\gcc\arm-apple-darwin\4.0.1\collect2.exe -dynamic 
-arch
arm -macosx_version_min 10.4 -syslibroot /usr/local/share/iphone-filesystem
-weak_reference_mismatches non-weak -o Example -lcrt1.o
-L/usr/local/lib/gcc/arm-apple-darwin/4.0.1
-L/usr/local/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/lib 
-lobjc
-framework Foundation -framework UIKit -framework CoreGraphics Example.o -lgcc
-lSystem -F/usr/local/share/iphone-filesystem/System/Library/Frameworks
-F/usr/local/share/iphone-filesystem/System/Library/PrivateFrameworks

[... and ...]

C:\cygwin\usr\local\bin\arm-apple-darwin-ld.exe -dynamic -arch arm
-macosx_version_min 10.4 -syslibroot /usr/local/share/iphone-filesystem
-weak_reference_mismatches non-weak -o Example -lcrt1.o
-L/usr/local/lib/gcc/arm-apple-darwin/4.0.1
-L/usr/local/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/lib 
-lobjc
-framework Foundation -framework UIKit -framework CoreGraphics Example.o -lgcc
-lSystem -F/usr/local/share/iphone-filesystem/System/Library/Frameworks
-F/usr/local/share/iphone-filesystem/System/Library/PrivateFrameworks

... hope this is of use. Tempted to throw in the towel at this point and 
reinstall
the toolchain (*arg*)

Original comment by randomn...@gmail.com on 30 Apr 2009 at 11:00

GoogleCodeExporter commented 8 years ago
Okay, managed to get the example above compiling/running, but ended up using the
instructions at http://www.saurik.com/id/4 using an iPod 2.0 firmware (instead 
of the
1.1.4 mentioned on that page), building against the MacOSX10.5 and iPhoneSDK2_0
libraries. Needed to fix some file permissions and symlinks during the process, 
but
that may have been due to the method used to decompress the firmware.

The arm-apple-darwin9-gcc that's generated from this process will exhibit the 
same
failure as described in this issue ("Undefined symbols:
.objc_class_name_NSAutoreleasePool") if the -fobjc-abi-version=1 flag is passed 
to
arm-apple-darwin9-gcc.  If -fobjc-abi-version=2 is supplied (or if the flag is 
not
present), then the binary appears to compile OK.  

Hope this helps.

Original comment by randomn...@gmail.com on 30 Apr 2009 at 9:20

GoogleCodeExporter commented 8 years ago
Yes, it works fine, i can now compile iPhone 2.2.1 Applications under cygwin.

Regards, Christian

Original comment by cla...@nw7.de on 2 May 2009 at 11:08