Dynamic linking on macOS: ImageIO.framework looks from the wrong path? - macos

After rebooting my dev machine, my Rust project stopped running on macOS. The error message is:
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
I have absolutely no idea what changed and caused this. The problem seems to be with my rig, not with the code, since it runs fine on a Docker container, and the older commits refuse to run on my computer. Another thing is that my project shouldn't be using any image-processing libraries. (And I don't know how to list transitive dynamic dependencies on macOS to check whether it really does.)
otool -L /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO reveals that ImageIO links to /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib (compatibility version 1.0.0, current version 1.0.0). That file exists indeed. /usr/local/lib/libjpeg.dylib (My FS is case-insensitive) exists too, but it's a symlink to a homebrewed file ../Cellar/jpeg/8d/lib/libjpeg.dylib, so clearly the system library shouldn't use that. However, I have not set LD_LIBRARY_PATH or any other env var that – as far as I know – should coerce macOS to use /usr/local/lib as a dylib search path.
So my questions are:
1) Is there a tool on macOS to check, which libraries in my project link (possibly transitively) to the ImageIO.framework?
2) How are dylib search paths configured on macOS? Is there a tool to check which paths are searched and in which preference order? The problem itself might be due to some Homebrew problem, but I'd like to have the tools to diagnose and understand it.

I still don't know a good answer for 1).
For 2) the answer can be found from the Apple docs. This page lists all the env vars that affect dylib loading and their default values: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
For the mystery, why the wrong path was attempted to be loaded: although my environment didn't have any funny variables set, my build tool (cargo run) set DYLD_LIBRARY_PATH before running the binaries. This is because of the behaviour (not sure if bug) explained here: https://github.com/sgrif/pq-sys/commit/3ad9f7b77a6c4f50d5d7277bce05c836a62a4398

Related

Trouble installing hmatrix through MSYS2 on Windows 10

I've been trying to install hmatrix on my (64-bit) Windows 10 computer; after searching through and trying many possible solutions (including the instructions under "Windows" and "Alternative Windows Build" given here), I decided to pursue the course of action given on this Reddit thread.
However, when I type in the command
cabal install hmatrix -fopenblas --extra-lib-dir=${c:\msys64\mingw64\bin} --extra-include-dir=${c:\msys64\mingw64\include}
into the MSYS2 shell, the following log is given:
Resolving dependencies...
Configuring hmatrix-0.17.0.2...
Failed to install hmatrix-0.17.0.2
Build log ( C:\Users\Christian\AppData\Roaming\cabal\logs\hmatrix-0.17.0.2.log ):
Configuring hmatrix-0.17.0.2...
cabal.exe: Missing dependency on a foreign library:
* Missing C library: libopenblas
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Leaving directory 'C:\msys64\tmp\cabal-tmp-4244\hmatrix-0.17.0.2'
cabal.exe: Error: some packages failed to install:
hmatrix-0.17.0.2 failed during the configure step. The exception was:
ExitFailure 1
However, when I check the directory c:\msys64\mingw64\bin, I see that libopenblas.dll is right there; I don't know why cabal can't seem to find it.
Any insight into why this is not working or what to do?
UPDATE:
The files libopenblas.dll.a and libopenblas.a are in the directory c:\msys64\mingw64\lib. Is it possible I need to somehow include this directory as well? (If I do, how would I do that?)
I also downloaded the files in Alex Vorobiev's comment below and put them in c:\msys64\mingw64\bin if they are .dlls or c:\msys64\mingw64\lib if they are .libs. The header files were already contained in c:\msys64\include\openblas.
I tried several variations on the command in the original post after making these changes, including switching \bin with \lib and switching \include with \include\openblas, but all of them still give the same error.
I'm a bit suspicious about the
if os(windows)
if flag(openblas)
extra-libraries: libopenblas
in the cabal file, could you unpack it and remove the "lib" part? If that doesn't work please post a log with -v3 output. I've seen quite a few people with troubles installing this package. So could you also open a ticket on the GHC bug tracker if this doesn't work (and CC me "Phyx-")?
Secondly, you never said which version of GHC you're using. 8.0.1 should have far less trouble (and won't need the hack to get it working in GHCi) since the runtime linker has been overhauled and should be much better on Windows. 8.0.2 will likely include the new import libraries support as well.

dyld: Library not loaded ... Reason: Image not found

When trying to run an executable I've been sent in Mac OS X, I get the following error
dyld: Library not loaded: libboost_atomic.dylib
Referenced from: /Users/"Directory my executable is in"
Reason: image not found
Trace/BPT trap:5
I have installed the boost libraries and they are located in /opt/local/lib. I think the problem has something to do with the executable only looking in the directory it is in as when I paste the 'libboost_atomic.dylib' in there, it doesn't mind about it anymore. Unfortunately then it complains it can't find the next boost library.
Is there an easy way to fix this?
Find all the boost libraries (where exefile is the name of your executable):
$ otool -L exefile
exefile:
#executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
and for each libboost_xxx.dylib, do:
$ install_name_tool -change #executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile
and finally verify using otool again:
$ otool -L exefile
exefile:
/opt/local/lib/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
Manpages: otool install_name_tool
EDIT A while back I wrote a python script (copy_dylibs.py) to work out all this stuff automatically when building an app. It will package up all libraries from /usr/local or /opt/local into the app bundle and fix references to those libraries to use #rpath. This means you can easily install third-party library using Homebrew and package them just as easily.
I have now made this script public on github.
This worked for me:
brew upgrade node
In the target's General tab, there is a section called Frameworks, Libraries, and Embedded Content
Click on the + sign, add required framework and the crash is resolved.
After upgrade Mac OS to Mojave. I tried to install npm modules via yarn command I got error:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
Was fixed with:
brew update
brew upgrade
For some, this could be as easy as setting the system path for dynamic libraries. On OS X, this is as simple as setting the DYLD_LIBRARY_PATH environment variable. See:
Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?
this should fix the issue
brew update
brew upgrade
brew cleanup
I got this error when I tried to install ruby 2.3.1 using rvm. It first told me to run brew update, which I did, and then when I tried running rvm install ruby-2.3.1, I received the error in this SO question.
The fix was to first run brew upgrade, apparently according to this superuser.com question you need to do both brew update && brew upgrade. Once that was done, I could finally install ruby 2.3.1.
Now that Xcode has upgraded their IDE, they have changed a little bit how this functions.
It used to be split up into separate section as demonstrated above with 'Embedded Binaries' and 'Linked Frameworks and Libraries' as separate sections.
Now, it is one combined section with drop-downs on the right as to what should be embedded.
This was confusing to me at first, but makes perfect sense now.
If you're using Xcode 11 onwards:
Go to General tab and add the framework in Frameworks, Libraries, and Embedded Content section.
Important: By default it might be marked as Do Not Embed, change it to Embed Without Signing like shown in the image and you are good to go.
For Xcode versions below 11:
Just add the framework in Embedded Binaries section and you are done.
Cheers!
To resolve the error below on my Macbook Catalina 10.15.4:
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/bin/mongoexport
Reason: image not found
Abort trap: 6
I ran the command below and got round the problem above:
brew switch openssl 1.0.2s
You can use the otool command with the -L option for the executable, which will display where the executable is expecting those libraries to be.
If the path to those need changing, use the install_name_tool command, which allows you to set the path to the libraries.
Making the Frameworks in the Build Phases Optional worked for me.
In Xcode -> Target -> Build Phases -> Link Binary with Libraries ->
Make sure the newly added frameworks if any are marked as Optional
I got here trying to run a program I just compiled using CMake. When I try to run it, it complains saying:
dyld: Library not loaded: libboost_system.dylib
Referenced from: /Users/path/to/my/executable
Reason: image not found
I circumvented the problem telling CMake to use the static version of Boost, instead of letting it use the dynamic one:
set(Boost_USE_STATIC_LIBS ON)
I fix it by brew install libpng
If you use cmake, add DYLIB_INSTALL_NAME_BASE "#rpath" to target properties:
set_target_properties(target_dyLib PROPERTIES
# # for FRAMEWORK begin
# FRAMEWORK TRUE
# FRAMEWORK_VERSION C
# MACOSX_FRAMEWORK_IDENTIFIER com.cmake.targetname
# MACOSX_FRAMEWORK_INFO_PLIST ./Info.plist
# PUBLIC_HEADER targetname.h
# # for FRAMEWORK end
IPHONEOS_DEPLOYMENT_TARGET "8.0"
DYLIB_INSTALL_NAME_BASE "#rpath" # this is the key point
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
DEVELOPMENT_TEAM "${DEVELOPMENT_TEAM}"
)
or in Xcode dynamic library project Target -> Build Setting set Dynamic Library Install Name Base to #rpath
I fixed this issue by using Product > Clean Build Folder (CommandShiftK), which makes a new clean build, really odd.
For my framework I was using an Xcode subproject added as a git submodule.
I believe I was getting this error because I was signing the framework with a different signing Team than my main app. (switched teams for app; forgot to switch for framework)
Solution is to not sign within the framework project. Instead, in the main app's Target > General > Frameworks, Libraries, and Embedded Content section, sign the framework via Embed & Sign.
If I select Do not Embed or Embed Without Signing I instead get the error:
FRAMEWORK not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
You can use sudo install_name_tool -change change dylib path
And
sudo install_name_tool -id change dylib name
if you use virtualenv just remove the folder of your environment and recreate it with this command
virtualenv --python=/usr/local/bin/python3 the_name_of_my_env
Xcode 11.1 & Swift 5.1
Quick Fix
First make sure that external added library has option embed is selected in General Tab, Embbed Binaries.
If still not works..
This happens because you have different, unmatched versions of libraries present.
Update the Pods
pod update
Important: Check all libraries are included in the Build Settings -> libraries and frameworks list and you have given option to embbed in the build
Just working awesome
In our case, it's an iOS app, built on Xcode 11.5, using cocoapods (and cocoapods-binary if you will).
We were seeing this crash:
dyld: Library not loaded: #rpath/PINOperation.framework/PINOperation
Referenced from: /private/var/containers/Bundle/Application/4C5F5E4C-8B71-4351-A0AB-C20333544569/Tellus.app/Frameworks/PINRemoteImage.framework/PINRemoteImage
Reason: image not found
Turns out that I had to delete the pods cache and re-run pod install, so Xcode would point this diff:
For anyone coming to this page because they got this error trying to link a third party framework to their project using Xcode 6.3.1, the problem I ran into was because the library was being created with an older version of the compiler using a different version of swift. The only way to fix this for me was to re-build the framework.
Another reason you might get this is stated in an Apple technical doc..
If you are building an app that does not use Swift but embeds content such as a framework that does, Xcode will not include these libraries in your app. As a result, your app will crash upon launching with an error message looking as follows:
set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app
Here is the link to the full Apple doc that explains it here
For anyone experiencing the same thing with a different library or package, #user3835452 is on the right track. I found this message while trying to run composer:
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/opt/php#7.1/bin/php
Reason: image not found
Abort trap: 6
After trying a lot of different ways I just ran brew install openldap and it fixed it. Note that I had already ran brew update and brew upgrade but only after I manually installed openldap did it actually work.
Is there an easy way to fix this?
I just used brew upgrade <the tool>. In my case, brew upgrade tmux.
In my case it was node that was out of date, you need to upgrade it after goin up to BigSur - brew upgrade node
As said in https://gist.github.com/berkedel/d1fc6d13651c16002f64653096d1fded, you could try
brew uninstall --ignore-dependencies node icu4c
brew install node
brew link --overwrite node
Quick Fix
Remove the pod (whose name is in the error) by commenting it in your Podfile, like #Podname
Run pod install
Uncomment the pod that you commented earlier
Run pod install again.
It worked for me and is easy to do so sharing it.
I faced the app crash issue quoting SIGABRT error in thread.Overview of the crash is dyld library not loaded and image not found something like that.
This was seen in Xcode 9.3. The reason I found out was Xcode is not picking up libraries dynamically so I had to do it manually which solved my crash issue.
Follow the below steps:
Go to Build Phases
Hit the '+' button at the top and select "New Copy File Phase"
Select Destination as Frameworks and Hit the '+' button below to add files.
Select Add Other at below, click CMD+SHIFT+G and paste the below path,
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Now you will be able to see some swift dylibs, Select all the swift libraries with .dylib extension and click on open.
These will get added to the embedded binaries in the general tab of app.
Create a new group in project folder and add all these libraries.
Now run your app.
If you are using Conda environment in the terminal, update the samtools to solve it.
conda install -c bioconda samtools
Best one is answered above first check what is the output of
otool -L
And then do the following if incorrect
set_target_properties(
MyTarget
PROPERTIES
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS
"#executable_path/Frameworks #loader_path/Frameworks"
)
And
set_target_properties(
MyTarget
PROPERTIES
XCODE_ATTRIBUTE_DYLIB_INSTALL_NAME_BASE
"#rpath"

Why doesn't OS X 10.8 Mountain Lion find X11 libraries when building software?

So, we all know that Mountain Lion doesn't ship with X11 anymore and users needing X11 are directed to download Xquartz. Xquartz installs to /opt, but it also symlinks X11 and X11R6 to /usr. But when building software that requires linking to X11 include files, I've discovered that I must pass an environment variable adding /usr/X11/include (or /opt/X11/include) to the library search path to get ./configure to find the X11 libraries. My question is why?
I've done some research on Google (many results pointing back to Stack Overflow), and I've read Apple's documentation, and these sources all indicate that there is no equivalent in OS X to the /etc/ld.so.conf file found in many (if not all) Linux distributions. Apple even states that DYLD_LIBRARY_PATH is empty by default. However, under Lion (with Apple's last 'official' X11 installed), the same ./configure scripts would find the X11 libraries without adding anything to the library search path.
So, why can't ./configure scripts find X11 libraries in Mountain Lion without explicit modification of the library search path?
Asked more than a year ago... but as I came here with a similar problem...
Note that in the mentioned ruby question, there was no library search path being modified.
That solution just set an environment variable that is picked up by many Makefiles as the flags for the C++ compiler. That example defined the build time -I ncludepath, i.e. where to search for .h eaders -- not libraries (which would have been a -L option to your compiler/linker). Both would have been build time options.
Whether LD_LIBRARY_PATH or DYLD_LIBRARY_PATH -- both are environment variables that are considered by the dynamic linker at runtime. (For more, see http://en.wikipedia.org/wiki/Dynamic_linker )
I have no pre-10.8 machine at hand, but guess that there might have been a symlink
/usr/include/X11 -> /opt/X11/include/X11 -- otherwise I have no Idea atm how
it could have worked before, assuming same sources...
This is another potential solution for such problems (just fixed my realvnc build):
$ autoconf
$ ./configure
So your question for "why?" could be eventually answered with: Because your sources contained a 'pre-built' configure script that was based on older autotools that did not include
/opt/X11/include as a potential location to search for X11 includes or simply did not get some of the above mentioned compile time flags right on your current system.
I have autoconf installed through homebrew -- ahh, great stuff, cheers.

Deploying Qt Frameworks with Mac app and usage of otool

I have a problem deploying Qt frameworks with my Mac app, and I hope some will have a clue why I get this error, when I run the app on clean Mac, i.e. not a developer Mac.
OS: 10.7 .2 and using XCode
Error msg:
Library not loaded: #loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from:/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Clearly something is wrong since the QtXml is referenced from /../Frameworks/../Frameworks, which doesn’t exists.
This is the set up: I have a dylib that uses QtCore and QtXml (not by my choosing, but for now I need those two frameworks), the dylib is used in a NSBundle, which is loaded by the main app, the bundle is located in the resource folder. The dylib is moved by Copy Files Build Phase to the folder Contents/Frameworks and with otool the install_name is set to (as stated by http://doc.qt.digia.com/4.3/deployment-mac.html):
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
#loader_path/../Frameworks/QtXml.framework/Versions/4/QtXml
then the Qt frameworks are moved to Contents/Frameworks and the install_name of the is set to:
#executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
and for the QtXml
#executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml
with reference to QtCore:
#executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Now when I run the app on the developer mac it clearly works since Qt is installed, but when moved to a clean mac I get the error msg, readable in the Console app.
I’ve tried to change the executable_path to loader_path, but this didn’t work.
I have no idea what I’m doing wrong or why it won't for, and have not been able to find anything on Google, of course I could be looking at the wrong places. Any ideas how to fix this problem?
This is the entire error message:
MainApp: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle
“Library” couldn’t be loaded because it is damaged or missing
necessary resources."
(dlopen_preflight(/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/
Contents/MacOS/Library): Library not loaded:
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from: /Users/ someUser /Downloads/
MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Reason: image not found) UserInfo=0x107c5d5d0
{NSLocalizedFailureReason=The bundle is damaged or missing necessary
resources., NSLocalizedRecoverySuggestion=Try reinstalling the
bundle.,
NSFilePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library,
NSDebugDescription=dlopen_preflight(/Users/someUser
/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library):
Library not loaded:
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from:
/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Reason: image not found,
NSBundlePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle,
NSLocalizedDescription=The bundle “Library” couldn’t be loaded because
it is damaged or missing necessary resources.}
On the development mac everything works because the Qt libraries are installed. On any mac you ship the app to, though, this likely won't be the case. The Qt suite comes with a tool called macdeployqt to fix this. So in a terminal, after you've compiled your application, do something like:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app
Note that it can also be used to create a .dmg file for shipping everything together:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app -dmg
Once you've done that, the .app directory or .dmg file can be given to someone else without Qt installed to use and run as they normally would.
The one caveat is that the next time you try to run it on your developer machine, it may complain about multiple shared libraries installed. So once you've copied it else where in order to distribute it, remove the entire .app directory and let qtcreator (or whatever) rebuild it.
UPDATE
As stated compiling QT to static libs is the way to go. With the release of Mavericks (10.9) we need to codesign frameworks as well (http://furbo.org/2013/10/17/code-signing-and-mavericks/), and with QT4.8.5 there are some issues (https://bugreports.qt-project.org/browse/QTBUG-32896). Even with suggested fixes I still had some issues when running the app on a clean machine. Therefore, I ended up with compiling Qt5.2 to staticlibs, link them in the app, and codesign them.
OLD
Problem sovled, I moved the Qt-frameworks into the app bundle in Contents/Frameworks and with otool set the path to #executable_path/../Frameworks, i.e. moved it out of my library bundle. Yes the solution is simple, but I'm still not sure why the library executable couldn't find the frameworks when using #loader_path.
The best solution would probably be to use a static library and not wrap it in a bundle...you learn everyday ;)

Static libraries in version-cross-compiled program

I have a unix command line app (with big nasty makefile) that I'm trying to run on a mac. I am compiling it on a 10.6 system, with all of the appropriate libraries of course. The deployment environment is a 10.5 system, with no extra libraries.
I compiled without -dynamic, and it appears to have static libraries, correctly. When I run it on the 10.6 system, it works. However, when I run it on the 10.5 system, I get:
dyld: unknown required load command 0x80000022
I got this same error when I compiled things for the 10.6 system using the 10.5 xcode, so it looks like a version mis-match type problem. However, I used gcc-4.0, and
$CFLAGS = -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
so it SHOULD be set up for 10.5... any ideas?
thanks
Editing an ancient question:
I have the exact same problem on a different computer. This time I am at 10.5.8, fully update, the same executable works on 10.6 still.
Has anyone had any luck with this in the months since I asked this?
The reason for the dyld 0×80000022 error can be that, you are linking on OS X 10.6, and OS X 10.6 will use a load command (LC_DYLD_INFO_ONLY = 0×80000022) that OS X 10.5 does not understand.
To fix this, make sure you are using a deployment target by setting the environment variable just before your link command:
export MACOSX_DEPLOYMENT_TARGET=10.5
(or setenv MACOSX_DEPLOYMENT_TARGET=10.5)
You can always check if your executable uses the right load command like this:
otool -l executable
It will either show LC_DYLD_INFO_ONLY (without deployment target) commands or LC_DYLD_INFO (with deployment target).
I have been searching for the same issue, as I develop on 10.6 but must have a version that works on 10.5. In addition to the compiler flags above, you should add:
-no_compact_linkedit
It is described here:
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/ld.1.html
where it says:
Normally when targeting Mac OS X 10.6, the linker will generate compact information in the __LINKEDIT segment. This option causes the linker to instead produce traditional relocation information.
I got there from a discussion on the xcode-users mailing list about "unknown required load command 0x80000022".
i was able to solve this by passing -mmacosx-version-min=10.5 to the linker, e.g. --extra-ldflags="-mmacosx-version-min=10.5" passed to configure for ffmpeg which i was building shared. more info: http://lists.apple.com/archives/xcode-users/2009/Oct/msg00530.html
Depending on how many libraries you use, it may be difficult to get all of them linked statically. What does "otool -L your_binary' tell you?
In order to get a self-contained package for an application of my own, I made a custom MacPorts install in a non-standard directory, so that I could dynlink with the libraries from that directory and only be constrained in asking people to install the whole thing in the same place on their computers. Not great, not the Mac spirit at all, but it's an Unix app and you need to be familiar with Unix to use it anyway.
Good luck
Pascal
It turns out that there is a dynamic library load function (0x22) that got added at 10.5.6. The system I was running on was 10.5.5. I upgraded to 10.5.8, and everything runs!
Ok, SECOND solution, and NOT very satisfying, is to find a 10.5.8 computer, install the developer packages and re-compile... same for powerPC... sad but it will work...

Resources