When i run an application built with C::B for mac it starts and quit immediatly. On console it writes:
dyld: lazy symbol binding failed: lazy pointer not found
dyld: lazy pointer not found
Trace/BPT trap
If you would google "dyld: lazy symbol binding failed: lazy pointer not found"
you will find all sorts of solutions to this problem.
Primary reason:
gcc packaged with 10.4 should not be used with the -s option. It over strips your programs and libraries. Do a separate strip (standalone) after you've tested your program.
Other mentioned solutions:
It's possible Mac cannot find your dylib. Use something like the following to set the library pointer
LIB=`pwd`
# or LIB=<path to my just compiled programs dylib>
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$LIB
export DYLD_LIBRARY_PATH
You might also have to give your program the great Mac blessing:
sudo /developer/tools/Rez -d __DARWIN__ -t APPL Carbon.r -o <my just compiled program>
Otherwise you can make it into a bundle like:
http://wxforum.shadonet.com/viewtopic.php?t=6045&highlight=
See at bottom of this link the section on Bundles
http://wiki.codeblocks.org/index.php?title=Compiling_Code::Blocks_in_Mac_OS_X
/Developer/Tools/SetFile -t APPL `pwd`/${1}
/developer/tools/Rez -d __DARWIN__ -t APPL Carbon.r -o `pwd`/${1}
Here's an example shell command that can be modified to run your program without bundling.
#!/ bin/sh
##^remove the blank before bin. It's here only to appease forum software
APP_DIR=/Users/pecan/devel/mac/trunk/src/devel/
export LD_LIBRARY_PATH=$APP_DIR:$LD_LIBRARY_PATH
LIB=$APP_DIR
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$LIB
export DYLD_LIBRARY_PATH
#--exec $APP_DIR/codeblocks --prefix=$DIR
echo DIR=$APP_DIR
echo LIB=$LIB
echo DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
echo command line =exec $APP_DIR/codeblocks --prefix="$APP_DIR"
exec $APP_DIR/codeblocks --prefix="$APP_DIR"
Now it seems to work. I've just seen solutions on google but i didn't find the SetFile / Rez one.
/Developer/Tools/SetFile -t APPL `pwd`/${1}
/developer/tools/Rez -d __DARWIN__ -t APPL Carbon.r -o `pwd`/${1}
By the way it's strange. Using that instructions it creates a mac os classic application. If i run from system it calls classic subsystem, if i call it from console it works as mac os x app. If i create a bundle it works as mac os x app too. But usually inside bundle the apps are not classic apps, are they?
Now i'm writing my own wizard to set post-build options too.
Thanks Pecan!
The rez thing should NOT be used. it is for legacy stuff (classic apps)
It's much better to build an app bundle. Quick example of how to do it:
Target > Build Options > Pre/post build steps
Pre-build steps:
mkdir -p $(TARGET_OUTPUT_DIR)/MyApp.app/Contents/MacOS
mkdir -p $(TARGET_OUTPUT_DIR)/MyApp.app/Contents/Resources
post-build step:
cp $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_DIR)/MyApp.app/Contents/MacOS
This is dirty and incomplete, but if you continue in that direction, add an info.plist file, fix executable location instead of copying it, etc. you can probably get it working quite well enough
If you can make a wizard out of that, please share it, it would be awesome :D