changeset 4761:31e12d2ce275

Linux Standard Base (LSB) builds of Orthanc can load non-LSB builds of plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Aug 2021 13:00:37 +0200
parents cb18a1869e4e
children c563b7ad9931
files NEWS OrthancServer/CMakeLists.txt OrthancServer/Resources/VersionScriptOrthanc.map
diffstat 3 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jul 21 10:46:46 2021 +0200
+++ b/NEWS	Mon Aug 02 13:00:37 2021 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Linux Standard Base (LSB) builds of Orthanc can load non-LSB builds of plugins
+
 
 Version 1.9.6 (2021-07-21)
 ==========================
--- a/OrthancServer/CMakeLists.txt	Wed Jul 21 10:46:46 2021 +0200
+++ b/OrthancServer/CMakeLists.txt	Mon Aug 02 13:00:37 2021 +0200
@@ -397,6 +397,16 @@
 
 target_link_libraries(Orthanc ServerLibrary CoreLibrary ${DCMTK_LIBRARIES})
 
+if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+  # The link flag below hides all the global functions so that a Linux
+  # Standard Base (LSB) build of Orthanc can load plugins that are not
+  # built using LSB (new in Orthanc 1.9.7)
+  set_property(
+    TARGET Orthanc
+    PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/Resources/VersionScriptOrthanc.map"
+    )
+endif()
+
 install(
   TARGETS Orthanc
   RUNTIME DESTINATION sbin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Resources/VersionScriptOrthanc.map	Mon Aug 02 13:00:37 2021 +0200
@@ -0,0 +1,13 @@
+# This is a version-script for the main Orthanc binary, that hides all
+# the global functions of the executable so that a Linux Standard Base
+# (LSB) build of Orthanc can load plugins that are not built using
+# LSB. Otherwise, the dynamic loader of the plugins will try to use
+# the global functions published by the Orthanc server, which results
+# in a segmentation fault if the data structures don't have the same
+# memory layout (e.g. debug vs. release, or another version of some
+# C/C++ library used both by Orthanc, typically jsoncpp).
+
+{
+local:
+  *;
+};