From 33d4217450ffb6c23f11f8d13ca2d79ed0f8673f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 19 Dec 2015 16:46:04 -0500 Subject: [PATCH] Fixed rpath shenanigans on OS X. --- build/GNUmakefile.test | 7 ++++++- darwin/GNUfiles.mk | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build/GNUmakefile.test b/build/GNUmakefile.test index 3893695a..3e2e9099 100644 --- a/build/GNUmakefile.test +++ b/build/GNUmakefile.test @@ -17,7 +17,12 @@ ifeq ($(TOOLCHAIN),gcc) LDFLAGS += -L$(OUTDIR) -lui # tell the dynamic loader to search in the executable path for shared objects # note: OS X's linker complains if we say -rpath= instead of -rpath, - LDFLAGS += -Wl,-rpath,'$$ORIGIN' + # also note that OS X doesn't use $ORIGIN - see http://jorgen.tjer.no/post/2014/05/20/dt-rpath-ld-and-at-rpath-dyld/ + ifeq ($(OS),darwin) + LDFLAGS += -Wl,-rpath,@executable_path + else + LDFLAGS += -Wl,-rpath,'$$ORIGIN' + endif else # TODO is there an equivalent to -L? LDFLAGS += $(OUTDIR)/libui.lib diff --git a/darwin/GNUfiles.mk b/darwin/GNUfiles.mk index 0c887ec2..02c533eb 100644 --- a/darwin/GNUfiles.mk +++ b/darwin/GNUfiles.mk @@ -60,6 +60,7 @@ LDFLAGS += \ # fortunately, we don't need any; Apple's linker warns about undefined symbols in -shared builds! # flags for setting soname +# note the explicit need for @rpath # TODO -current_version, -compatibility_version LDFLAGS += \ - -Wl,-install_name,$(NAME).$(SOVERSION)$(SUFFIX) + -Wl,-install_name,@rpath/$(NAME).$(SOVERSION)$(SUFFIX)