Fixed shared library loading in the Python package (#2461)

* Fixed DLL name on Windows in ``xgboost.libpath``

* Added support for OS X to ``xgboost.libpath``

* Use .dylib for shared library on OS X

This does not affect the JNI library, because it is not trully
cross-platform in the Makefile-build anyway.
This commit is contained in:
Sergei Lebedev
2017-06-29 01:50:50 +02:00
committed by Rory Mitchell
parent 2911597f3d
commit 88488fdbb9
2 changed files with 14 additions and 8 deletions

View File

@@ -67,12 +67,15 @@ ifndef LINT_LANG
LINT_LANG= "all"
endif
ifneq ($(UNAME), Windows)
CFLAGS += -fPIC
XGBOOST_DYLIB = lib/libxgboost.so
else
ifeq ($(UNAME), Windows)
XGBOOST_DYLIB = lib/libxgboost.dll
JAVAINCFLAGS += -I${JAVA_HOME}/include/win32
else ifeq ($(UNAME), Darwin)
XGBOOST_DYLIB = lib/libxgboost.dylib
CFLAGS += -fPIC
else
XGBOOST_DYLIB = lib/libxgboost.so
CFLAGS += -fPIC
endif
ifeq ($(UNAME), Linux)
@@ -162,7 +165,7 @@ lib/libxgboost.a: $(ALL_DEP)
@mkdir -p $(@D)
ar crv $@ $(filter %.o, $?)
lib/libxgboost.dll lib/libxgboost.so: $(ALL_DEP)
lib/libxgboost.dll lib/libxgboost.so lib/libxgboost.dylib: $(ALL_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o %a, $^) $(LDFLAGS)