Skip to content

Commit

Permalink
Fix cpp examples build on Mac. (apache#13826)
Browse files Browse the repository at this point in the history
This is a regression of addning @rpath name to libmxnet.so on Mac,
example executable is not able to find libmxnet.so anymore.
Add @rpath search path to fix this issue.
  • Loading branch information
frankfliu authored and haohuw committed Jun 23, 2019
1 parent cd310bd commit 65785c2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cpp-package/example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# specific language governing permissions and limitations
# under the License.

ifeq ($(OS),Windows_NT)
UNAME_S := Windows
else
UNAME_S := $(shell uname -s)
endif

prebuild :
@mkdir -p build
$(shell ./get_data.sh)
Expand All @@ -30,6 +36,7 @@ endif

# CPPEX_CFLAGS += -I../include
CPPEX_EXTRA_LDFLAGS := -L../../lib -lmxnet
MXNET_LIB_PATH := $(shell cd ../../lib; pwd)

.PHONY: all clean

Expand All @@ -38,10 +45,12 @@ all: prebuild $(CPPEX_EXE)
debug: CPPEX_CFLAGS += -DDEBUG -g
debug: prebuild all



$(CPPEX_EXE):% : %.cpp
$(CXX) -std=c++11 $(CFLAGS) $(CPPEX_CFLAGS) -o build/$@ $(filter %.cpp %.a, $^) $(CPPEX_EXTRA_LDFLAGS)
ifeq ($(UNAME_S), Darwin)
install_name_tool -add_rpath @loader_path build/$@
install_name_tool -add_rpath $(MXNET_LIB_PATH) build/$@
endif

clean:
@rm -rf build

0 comments on commit 65785c2

Please sign in to comment.