fix library install name on OSX for relative path linking
authorEvan Shelhamer <shelhamer@imaginarynumber.net>
Sat, 20 Feb 2016 23:45:31 +0000 (15:45 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Sat, 20 Feb 2016 23:50:14 +0000 (15:50 -0800)
for linking of the caffe tools, tests, etc. the library install name
needs to include the @rpath set for the executables and interfaces

this was broken on OSX by #3311

Makefile

index 598d28d..3863503 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -283,9 +283,8 @@ ifeq ($(OSX), 1)
        # boost::thread is called boost_thread-mt to mark multithreading on OS X
        LIBRARIES += boost_thread-mt
        # we need to explicitly ask for the rpath to be obeyed
-       DYNAMIC_FLAGS := -install_name @rpath/libcaffe.so
        ORIGIN := @loader_path
-       VERSIONFLAGS += -Wl,-install_name,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
+       VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
 else
        ORIGIN := \$$ORIGIN
 endif
@@ -552,7 +551,7 @@ $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)
 
 $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
        @ echo LD -o $@
-       $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS)
+       $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)
        @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
 
 $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)