简体   繁体   English

在Mac OSX 10.5上使用ffmpeg dylibs的Cocoa应用程序崩溃(但不是10.6或10.7)

[英]Cocoa app with ffmpeg dylibs crashes on Mac OSX 10.5 (but not 10.6 or 10.7)

I've built a Cocoa project in Xcode that integrates the ffmpeg dylibs. 我在Xcode中构建了一个集成了ffmpeg dylibs的Cocoa项目。 It runs fine on Mac OSX 10.6 and 10.7 but it crashes on 10.5. 它在Mac OSX 10.6和10.7上运行良好,但它在10.5上崩溃。 I'm compiling on 10.6. 我正在编译10.6。 Any suggestions? 有什么建议么? Thanks! 谢谢!

Here's how I've compiled it: 这是我编译它的方式:

./configure --disable-static --enable-shared --disable-outdev=sdl --enable-runtime-cpudetect --disable-bzlib --disable-libfreetype --disable-libopenjpeg --enable-zlib --arch=x86_64 --sysroot=/Developer/SDKs/MacOSX10.6.sdk --extra-cflags="-isysroot /Developer/SDKs/MacOSX10.6.sdk -DMACOSX_DEPLOYMENT_TARGET=10.5 -mmacosx-version-min=10.5" ./configure --disable-static --enable-shared --disable-outdev = sdl --enable-runtime-cpudetect --disable-bzlib --disable-libfreetype --disable-libopenjpeg --enable-zlib --arch = x86_64 --sysroot = / Developer / SDKs / MacOSX10.6.sdk --extra-cflags =“ - isysroot /Developer/SDKs/MacOSX10.6.sdk-DMACOSX_DEPLOYMENT_TARGET = 10.5 -mmacosx-version-min = 10.5”

Here's the crash report: 这是崩溃报告:

Process:         MyApp [27963]
Path:            /Applications/MyApp.app/Contents/MacOS/MyApp
Identifier:      com.mycompany.MyApp
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  launchd [66]

Interval Since Last Report:          123326 sec
Crashes Since Last Report:           2
Per-App Interval Since Last Report:  0 sec
Per-App Crashes Since Last Report:   2

Date/Time:       2011-11-06 15:29:51.154 -0500
OS Version:      Mac OS X 10.5.8 (9L31a)
Report Version:  6
Anonymous UUID:  D86EA304-DCDA-4855-9124-69FE8C5BDE1B

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread:  0

Dyld Error Message:
  Library not loaded: @rpath/libavcodec.dylib
  Referenced from: /Applications/MyApp.app/Contents/MacOS/../Frameworks/MyEngine.framework/Versions/A/MyEngine
  Reason: no suitable image found.  Did find:
    /Applications/MyApp.app/Contents/Frameworks/MyEngine.framework/Versions/A/Libraries/libavcodec.dylib: unknown required load command 0x80000022

I believe the problem you're running into is that libavcodec isn't fully 64-bit compatible under 10.5. 我相信你遇到的问题是libavcodec在10.5下并不完全是64位兼容的。 I'm not 100% certain of this though. 我不是100%肯定这一点。

64-bit support wasn't fully fleshed out in 10.5 and so for most of my own 64-bit-native apps, I have to explicitly tell the OS to run the 32-bit versions of my binary when running under 10.5. 在10.5中没有完全充实64位支持,因此对于我自己的大多数64位原生应用程序,我必须明确告诉操作系统在10.5下运行时运行32位版本的二进制版本。

To do this, go into your Info.plist file and add in these flags: 为此,请进入Info.plist文件并添加以下标志:

<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
    <key>i386</key>
    <string>10.5.0</string>
    <key>ppc</key>
    <string>10.5.0</string>
    <key>x86_64</key>
    <string>10.6.0</string>
</dict>

This will ensure your app runs in 32-bit mode on Leopard machines and 64-bit mode (if appropriate) on your 10.6 & newer machines. 这将确保您的应用程序在Leopard计算机上以32位模式运行,并在10.6和更新的计算机上以64位模式(如果适用)运行。

Binaries compiled on 10.6 don't work on earlier OS X versions because 10.6 adds new dyld load commands that are not supported (did not exist) in 10.5 and earlier. 在10.6上编译的二进制文件不适用于早期的OS X版本,因为10.6添加了10.5及更早版本中不支持(不存在)的新dyld加载命令。

Although you are trying to add -mmacosx-version-min=10.5 to the flags which is commendable, you did not add it to the linking step, so the linker will still produce a dyld for 10.6. 虽然您尝试将-mmacosx-version-min=10.5添加到值得称赞的标志中,但您没有将其添加到链接步骤,因此链接器仍将生成10.6的dyld。

The above is the reason for the error, but you may further get into trouble for using 10.6 SDK - you should really use 10.5 SDK if you want to target Leopard. 以上是出错的原因,但是使用10.6 SDK可能会进一步遇到麻烦 - 如果你想要定位Leopard,你应该使用10.5 SDK。 Using 10.6 SDK may work on 10.5 if no 10.6-specific features are used, but it will crash if they are used since the compiler won't warn about them at compile time as they are expected to exist. 如果没有使用10.6特定功能,则使用10.6 SDK可以在10.5上工作,但如果使用它们将会崩溃,因为编译器不会在编译时警告它们,因为它们应该存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM