Error when using a compiled version of the OHIF plugin

Hi all,

I recently compiled the OHIF plugin from this documentation, the compilation was successful but when I used the plugin with my containerized Orthanc I received this error.

2023-06-23 19:25:43 E0623 13:55:43.651340 SharedLibrary.cpp:98] dlopen(/usr/share/orthanc/plugins/libOrthancOHIF.so) failed: Error /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/share/orthanc/plugins/libOrthancOHIF.so)
2023-06-23 19:25:43 E0623 13:55:43.653585 main.cpp:2091] Uncaught exception, stopping now: [Error while using a shared library (plugin)] (code 25)

I have mounted the plugin as a volume to my docker container like this:

  orthanc:
    ...
    environment:
      OHIF_PLUGIN_ENABLED: true
    volumes:
     ...
      - ./libOrthancOHIF.so:/usr/share/orthanc/plugins/libOrthancOHIF.so

I suspect this is due to the CMake version but I am not too sure.

  • I have used CMake version 3.22.1 and
  • osimis/orthanc:master-full-stable image

This is my first Orthanc CMake build, any help with this is super appreciated!

Regards,
Yash

Hello,

In GNU/Linux distributions, you cannot simply copy/paste shared libraries from one distribution to another. You have to compile the shared libraries on the target platform (in the case of the osimis/orthanc Docker images, this is Debian 11 - bullseye) . This is why the Orthanc project provides Linux Standard Base binaries that are statically linked, which makes them compatible with most GNU/Linux distributions.

Kind Regards,
Sébastien-

Hi,

How do I go about building the Orthanc with the custom OHIF plugin?

Also, I have Lua & python scripts, do I have to pass the script files on build or can I simply build, containerize and then pass the script files as docker volumes?

Also for other plugins such as PostgreSQL, can I simply use the LSB binaries as volumes?

Regards,
Yash

Hi,

How do I go about building the Orthanc with the custom OHIF plugin?

The full sources to rebuild osimis/orthanc Docker image is available in this repo. You can get inspiration from there if you want to build a custom OHIF plugin !?!. BTW, the OHIF plugin is already included like all other plugins.

Also, I have Lua & python scripts, do I have to pass the script files on build or can I simply build, containerize and then pass the script files as docker volumes?

You may pass them through a docker volume

Also for other plugins such as PostgreSQL, can I simply use the LSB binaries as volumes?

That should probably work but again, quite a weird idea since the plugins are included in the images.

Best regards,

Alain.

Hi @alainmazy

Perhaps my questions were unclear.

  1. The OHIF plugin takes the dist folder of the OHIF build, and I want to use my dist instead of the default one. How do I achieve that for osimis/orthanc?

  2. For PostgreSQL plugin, I do not intend to build it. I want to use it with my Orthanc build.

Update:

@alainmazy I tried the orthanc-builder repository and got this CMAKE error for OE2:

#5 136.5 -- Looking for uuid_generate_random in /usr/lib/x86_64-linux-gnu/libuuid.so
#5 136.5 -- Looking for uuid_generate_random in /usr/lib/x86_64-linux-gnu/libuuid.so - found
#5 136.6 -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0")  
#5 136.8 -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: filesystem thread system date_time regex iostreams 
#5 136.8 CMake Error at CMakeLists.txt:149 (if):
#5 136.8   if given arguments:
#5 136.8 
#5 136.8     "STREQUAL" "mainline"
#5 136.8 
#5 136.8   Unknown arguments specified
#5 136.8 
#5 136.8 
#5 136.8 -- Configuring incomplete, errors occurred!
#5 136.8 See also "/build/CMakeFiles/CMakeOutput.log".
#5 136.8 See also "/build/CMakeFiles/CMakeError.log".
#5 ERROR: executor failed running [/bin/sh -c /scripts/build-or-download.sh target=orthanc-explorer-2 commitId=$ORTHANC_OE2_COMMIT_ID extraArg1=$ORTHANC_OE2_VERSION baseImage=$PLATFORM/$BASE_IMAGE_TAG preferDownloads=$PREFER_DOWNLOADS enableUploads=$ENABLE_UPLOAD]: exit code: 1

I used this command to build the image

./local-build.sh version=stable skipCommitChecks=1 image=normal

I’ve been reworking this script a lot lately and have not tried it yet with the skipCommitChecks=1. You may try it without that while I investigate.

@alainmazy no change in the error after I removed skipCommitChecks=1.

What command are you using to build the image?
I have cloned the orthanc-builder master branch and I am using Debian WSL to run the build scripts.

Also, do I need to add a .env?

Both commands works on my side with or without skipCommitChecks.
Note that there are a few prerequisites like having Mercurial and Git installed

I’ve had the same problem. I think the problem is that GLIBCXX_3.4.29 does not get included in the static build and is not natively available in osimis/orthanc images.

RUN echo ‘deb Index of /debian testing main’ > /etc/apt/sources.list.d/testing.list && echo ‘APT::Default-Release "stable";’ > /etc/apt/apt.conf.d/99default-release && apt-get update && apt-get install -y -t testing libstdc++6

You can use above command in the Dockerfile that builds the image where Orthanc is running from as a workaround. I’m not sure if this will affect other functionality though.

To compile the OHIF plugin with your OHIF source:

  1. Clone plugin mercurial repo as “plugin-source” folder in your working directory
  2. replace build.sh with:

#!/bin/bash
set -ex
cp -r /source/viewer /tmp/
cd /tmp/viewer
HOME=/tmp yarn install --frozen-lockfile
HOME=/tmp QUICK_BUILD=true PUBLIC_URL=./ yarn run build
cp -r /tmp/viewer/platform/app/dist/* /target

  1. Clone your viewer source repository in “viewer-source” folder

Run the following:

docker run --rm
-v $(pwd)/plugin-source:/source
-v $(pwd)/viewer-source:/source/viewer
-v $(pwd)/build:/Build
-w /Build
osimis/orthanc-builder-base:bullseye-20230522-slim-stable bash -c "
export DEBIAN_FRONTEND=noninteractive &&
apt-get --assume-yes update &&
apt-get --assume-yes install npm &&
curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && apt-get install -y nodejs &&
npm install --global yarn &&
mkdir /target &&
chmod +x /source/Resources/CreateOHIFDist/build.sh &&
/source/Resources/CreateOHIFDist/build.sh &&
mkdir -p /source/OHIF/dist &&
cp -r /target/* /source/OHIF/dist &&
cmake /source -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DALLOW_DOWNLOADS=ON -DUSE_SYSTEM_ORTHANC_SDK=OFF &&
make"

You should get the artifact in /build folder mounted within your directory.