Skip to content
Browse files

Fix library install_name on Mac OS X

On Mac OS X, each shared library has an “install_name” property that
should be set to the absolute path of the library's installation
location, since this is how OS X find libraries at launch time.  In
waf, this is easy enough — just include the “osx” tool into your
wscript.

Unfortunately, this breaks waf unit testing [1], since you can longer
run the test executables directly from the build directory.  Normally,
the test framework sets DYLD_LIBRARY_PATH so that the test executables
find the newly compiled libraries in the build directory.  However,
the install path includes the full three-digit vnum of the shared
library, while the file produced in the build directory doesn't.  (At
install time, the no-vnum file is renamed into the with-vnum file.)

In the waf bug [1], we've submitted a patch that fixes this, which is
included in a new waf script in this project template.  It creates an
additional symlink in the build directory that contains the
three-digit vnum, so that the test executables can find their
libraries.

[1] http://code.google.com/p/waf/issues/detail?id=721
  • Loading branch information...
1 parent 6021c5a commit 4771e4f10d4d6e4768d5310b867b7fa770dd00e0 Douglas Creager committed Aug 12, 2010
Showing with 49 additions and 0 deletions.
  1. +46 −0 run.sh
  2. +3 −0 src/wscript
  3. BIN waf
View
46 run.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Usage: run.sh [debug|release] program arguments
+#
+# Runs a program from one of the build directories, with
+# LD_LIBRARY_PATH set correctly so that it can find all of the shared
+# libraries before they're installed.
+
+
+# Check that there are enough command-line parameters.
+
+if [ $# -lt 1 ]; then
+ echo "Usage: run.sh [debug|release] program arguments"
+ exit 1
+fi
+
+
+# Verify that the user chose a valid build type.
+
+BUILD="$1"
+shift
+
+case "$BUILD" in
+ debug)
+ ;;
+ release)
+ ;;
+ *)
+ echo "Unknown build type $BUILD"
+ exit 1
+ ;;
+esac
+
+
+# Find all of the src subdirectories in the build directory, and use
+# those as the LD_LIBRARY_PATH.
+
+SRC_DIRS=$(find build/$BUILD -name src)
+JOINED=$(echo $SRC_DIRS | perl -ne 'print join(":", split)')
+
+
+# Run the desired program, and pass on any command-line arguments
+# as-is.
+
+LD_LIBRARY_PATH="$JOINED:$LD_LIBRARY_PATH" \
+DYLD_LIBRARY_PATH="$JOINED:$DYLD_LIBRARY_PATH" \
+ "$@"
View
3 src/wscript
@@ -11,13 +11,16 @@
def set_options(opt):
opt.tool_options("compiler_cc")
opt.tool_options("misc")
+ opt.tool_options("osx")
def configure(conf):
conf.check_tool("compiler_cc")
conf.check_tool("misc")
+ conf.check_tool("osx")
conf.check_cfg(atleast_pkgconfig_version="0.15.0")
+
conf.check_cfg(
package="glib-2.0",
uselib_store="GLIB",
View
BIN waf
Binary file not shown.

0 comments on commit 4771e4f

Please sign in to comment.
Something went wrong with that request. Please try again.