OSXで配布するプログラムを動的リンクライブラリで作成した場合、最終的にライブラリの見ているファイルを変更しなくてはいけない。OSXの作法としては、Hoge.app/Contents/MacOS以下にライブラリをぶち込めばいいらしい。
ちなみに
Windowsの場合は特に何もしなくてもDLLを実行ファイルの場所に置けばOK
Linuxの場合はLD_LIBRALY_PATHでライブラリを指定する
やっぱMacめんどいな
その時のメモ。
まずotool -Lの出力を見る
otoolでそれぞれのライブラリがどれを見ているか調べる
$ for f in $(ls libwx_baseu-*); do otool -L ${f} ; done libwx_baseu-2.9.5.0.0.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 153.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 17.0.0) /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 19.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 53.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0) libwx_baseu-2.9.5.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 153.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 17.0.0) /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 19.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 53.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0) libwx_baseu-2.9.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 153.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 17.0.0) /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 19.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 53.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0)
フレームワークとlibc++はWindowsでいうところのWIN32APIなので除外、よってこの3つのために設定変更が必要
libwx_baseu-2.9.5.0.0.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0) libwx_baseu-2.9.5.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0) libwx_baseu-2.9.dylib: /usr/local/lib/libwx_baseu-2.9.dylib (compatibility version 1.0.0, current version 1.0.0)
install_name_tool
install_name_toolというものがMacにはあるみたいだ。そいつを使ってライブラリが見ているファイルを変えなければいけない。
参考1:Distributing WxWidgets Applications-Distributing WxMac Programs - WxWiki
参考2:Deploying Applications on Mac OS X
使い方を日本語で説明しようと思ったけど、すでに書かれている方がいるのでリンクを貼らせていただきます
install_name_toolの使い方 - 半空洞男女関係