diff --git a/scripts/Linux/2_deploy.sh b/scripts/Linux/2_deploy.sh index d40bd8344..6b61d6bac 100644 --- a/scripts/Linux/2_deploy.sh +++ b/scripts/Linux/2_deploy.sh @@ -43,12 +43,18 @@ chmod +x $INSTALL_PATH/usr/bin/meshlab for plugin in $INSTALL_PATH/usr/lib/meshlab/plugins/*.so do - patchelf --set-rpath '$ORIGIN/../../:$ORIGIN' $plugin + # allow plugins to find linked libraries in usr/lib, usr/lib/meshlab and usr/lib/meshlab/plugins + patchelf --set-rpath '$ORIGIN/../../:$ORIGIN/../:$ORIGIN' $plugin done -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_PATH/usr/lib $RESOURCES_PATH/linux/linuxdeploy --appdir=$INSTALL_PATH \ --plugin qt +# after deploy, all required libraries are placed into usr/lib, therefore we can remove the ones in +# usr/lib/meshlab (except for the ones that are loaded at runtime) +shopt -s extglob +cd $INSTALL_PATH/usr/lib/meshlab +rm -v !("libIFXCore.so"|"libIFXExporting.so"|"libIFXScheduling.so") + #at this point, distrib folder contains all the files necessary to execute meshlab echo "$INSTALL_PATH is now a self contained meshlab application" diff --git a/scripts/Linux/3_pack.sh b/scripts/Linux/3_pack.sh index ac14fd77d..b4c391f13 100644 --- a/scripts/Linux/3_pack.sh +++ b/scripts/Linux/3_pack.sh @@ -31,7 +31,6 @@ case $i in esac done -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_PATH/usr/lib $RESOURCES_PATH/linux/linuxdeploy --appdir=$INSTALL_PATH \ --output appimage diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6d4eec1d..a446d4d3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,8 +43,8 @@ if (MESHLAB_USE_DEFAULT_BUILD_AND_INSTALL_DIRS) # otherwise, we assume that all include(GNUInstallDirs) if(INSTALL_TO_UNIX_LAYOUT) set(MESHLAB_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) - set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) - set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/meshlab/plugins) + set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/meshlab) + set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/plugins) set(MESHLAB_SHADER_INSTALL_DIR ${CMAKE_INSTALL_DATAROOTDIR}/meshlab/shaders) elseif(APPLE) set(MESHLAB_BIN_INSTALL_DIR .) @@ -60,7 +60,7 @@ if (MESHLAB_USE_DEFAULT_BUILD_AND_INSTALL_DIRS) # otherwise, we assume that all ### Install Settings if (NOT APPLE) - set(CMAKE_INSTALL_RPATH $ORIGIN/../${MESHLAB_LIB_INSTALL_DIR};$ORIGIN/../${CMAKE_INSTALL_LIBDIR}) + set(CMAKE_INSTALL_RPATH $ORIGIN/../lib/meshlab) else() SET(CMAKE_INSTALL_RPATH @executable_path/../Frameworks) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 73f864870..c4ddb0d19 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -180,6 +180,6 @@ if(MESHLAB_ENABLE_DEBUG_LOG_FILE) endif() set_target_properties(meshlab-common PROPERTIES - INSTALL_RPATH "${MESHLAB_LIB_INSTALL_DIR}:${INSTALL_RPATH}") + INSTALL_RPATH "$ORIGIN") install(TARGETS meshlab-common DESTINATION ${MESHLAB_LIB_INSTALL_DIR}) diff --git a/src/meshlabplugins/io_u3d/io_u3d.cpp b/src/meshlabplugins/io_u3d/io_u3d.cpp index bff0358ff..963ac13d4 100644 --- a/src/meshlabplugins/io_u3d/io_u3d.cpp +++ b/src/meshlabplugins/io_u3d/io_u3d.cpp @@ -35,22 +35,35 @@ #include #include +#ifdef __linux__ + +#define _GNU_SOURCE +#include +#include + +/** + * @brief returns the path of the shared object file that contains this function, which is + * the path where the shared object (libio_u3d.so) is placed in the system. + */ +std::string getLibPath() { + Dl_info dlInfo; + dladdr((void*)getLibPath, &dlInfo); + if (dlInfo.dli_sname != NULL && dlInfo.dli_saddr != NULL) { + // the full path, included libio_u3d.so + std::string path = dlInfo.dli_fname; + // remove from the path everything after the last occurrence of '/' + path = path.substr(0, path.find_last_of('/')); + return path; + } + else { + return std::string("."); + } +} +#endif + using namespace std; using namespace vcg; -#ifdef BUILD_MODE -const std::string LIB_IDTF_PATH = "../external/downloads/u3d-1.5.0"; -#else -#ifdef __APPLE__ -const std::string LIB_IDTF_PATH = "../Frameworks"; -#elif __linux__ -const std::string LIB_IDTF_PATH = "../lib"; -#else -const std::string LIB_IDTF_PATH = "."; -#endif -#endif - - U3DIOPlugin::U3DIOPlugin() : QObject(), IOPlugin() { @@ -75,6 +88,18 @@ void U3DIOPlugin::save( const RichParameterList & par, vcg::CallBackPos *) { +#ifdef BUILD_MODE + const std::string LIB_IDTF_PATH = "../external/downloads/u3d-1.5.1"; +#else +#ifdef __APPLE__ + const std::string LIB_IDTF_PATH = "../Frameworks"; +#elif __linux__ + const std::string LIB_IDTF_PATH = getLibPath() + "/.."; +#else + const std::string LIB_IDTF_PATH = "."; +#endif +#endif + vcg::tri::Allocator::CompactVertexVector(m.cm); vcg::tri::Allocator::CompactFaceVector(m.cm);