# Undefined symbol when run my CLI modules extensions

**URL:** <https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393>\
**Category:** Development\
**Created:** [March 21, 2018, 9:06pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393 "2018-03-21T21:06:46Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 21, 2018, 9:06pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/1 "2018-03-21T21:06:46Z")

</div>

Operating system: Ubuntu 16  
Slicer version: 4.8.1  
Expected behavior: cli working  
Actual behavior: not working

my cli extension are not working “anymore”. I get these errors:

```
undefined symbol: _ZN3itk13ProcessObject8SetInputERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_10DataObjectE

```

I tried install using the zipped file generated by make package. I also tried copy the libs to slicer related folder but I get the same error.

Just checked now, they only work using Slicer-build/Slicer but not the installed binary Slicer. What should I do to make them works in the binary as they used to do.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2018, 9:38pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/2 "2018-03-21T21:38:00Z")

</div>

Your build seems to be ABI incompatible with the official Slicer build binaries.

If you are lucky then you may be able to create an ABI-compatible library on a different computer, if you use exactly the same build environment and libraries, but practically you can only ensure compatibility if you build Slicer core and all extensions on the same computer. It can be your computer - for private distributions; or the Slicer build machines - for public distribution.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 22, 2018, 4:06am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/3 "2018-03-22T04:06:54Z")

</div>

For reference, here is the unmangled name of the missing symbol:

```auto
$ echo "_ZN3itk13ProcessObject8SetInputERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_10DataObjectE" | c++filt 
itk::ProcessObject::SetInput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, itk::DataObject*)

```

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 22, 2018, 4:17am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/4 "2018-03-22T04:17:48Z")

</div>

Also, as illustrated in commit [InsightSoftwareConsortium/ITK@01580b3](https://github.com/InsightSoftwareConsortium/ITK/commit/01580b37063ab3eeaa60a9f18068844b4d40e9f5), the method `itk::ProcessObject::SetInput` was part of the deprecated API.

Worth noting that while Slicer is built against an ITK having `ITKV3_COMPATIBILITY` option `OFF`, the option `ITK_LEGACY_REMOVE` is still `OFF`. See [here](https://github.com/Slicer/Slicer/blob/68a09496a6b64dde7ebabaceb822c29ace7f9a20/SuperBuild/External_ITKv4.cmake#L100)

Anticipating the transition to ITK 5.0, we will look into turning that option `ON` . This is captured in the following issue: [https://issues.slicer.org/view.php?id=4522](https://issues.slicer.org/view.php?id=4522)

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 22, 2018, 8:47am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/5 "2018-03-22T08:47:52Z")

</div>

I don’t understand, what changed? the extension works before, why I have this incompatibility now with the new [build](https://discourse.slicer.org/t/slicer-r26813-produces-4-9-lib/2379/4) that supposed to be the same as the binary 4.8.1? I thought Cmake take care of these things. I also tested with skipping [RPATH](https://cmake.org/Wiki/CMake_RPATH_handling) but I get the same error.

Thank Jean for the info.

I modify SuperBuild/External\_ITKv4.cmake to enable make ITKV3\_Compatibility. I also enabled the related module in ITKv4-build then rebuilt Slicer. After that, I rebuilt the extension but I got this error

```
undefined symbol: _ZN6vtksys11SystemTools24GetFilenameLastExtensionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE   

```

I checked it using:  
echo “\_ZN6vtksys11SystemTools24GetFilenameLastExtensionERKNSt7\_\_cxx1112basic\_stringIcSt11char\_traitsIcESaIcEEE” | c++filt  
vtksys::SystemTools::GetFilenameLastExtension(std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const&)

It looks there are some option I need to change in VTK?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 22, 2018, 12:02pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/6 "2018-03-22T12:02:30Z")

</div>

You should not have to modify the `ITKV3_Compatibility` option of Slicer. Instead, it should be possible to update your extension code to note use any legacy code. This is definitively the way forward.

How are you building your Slicer extension ?

Could you confirm you do something like this:

```nohighlight
mkdir my-extension-build
cd my-extension-build
cmake -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build ../my-extension-src
make

```

In the `my-extension-build/CMakeCache.txt` of your extension, what is the value for `ITK_DIR` ? It should be `/path/to/Slicer-Superbuild/ITKv4-build`

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 22, 2018, 2:29pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/7 "2018-03-22T14:29:54Z")

</div>

You are right. I will try to update the code and rebuild again. It is just not clear why it works before and not working now.

I build the extension the same way you mentioned. I checked CMakeCashe.txt , ITK\_DIR uses my Slicer-build/ITKv4-build

**Update:**

I package my Slicer build using

```
Slicer-build/make package  

```

I installed extensions from Slicer but it does not work. Looks like the build is incompatible as @lassoan mentioned. I rebuild again but the problem is still there.

What could possible gone wrong? I am using the source code for the same binary revision 4.8.1 using the same tools versions as mentioned in the instruction web-page e.g. Qt4.8.7.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 22, 2018, 10:55pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/8 "2018-03-22T22:55:40Z")

</div>

Instead of packaging and installing your extension, I suggest you backtrack and try the following:

- start Slicer from your build tree
- go to Edit -\> Settings -\> Modules, then add the paths to your module
- restart Slicer

Is the module properly loaded ?

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 23, 2018, 6:33pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/9 "2018-03-23T18:33:45Z")

</div>

There is no problem with the locally built extensions and the locally Slicer. The problem is with the extensions built locally with the binary Slicer downloaded from Slicer website.

Today, I built Slicer in 2 different machines (Ubuntu 16). I got the same error. So probably there is something wrong with the source or there is something installed affect the build.

I will make a clean install of Ubuntu 16 and try again. Is there a away to test the ABI incompatibility without building and testing the extensions?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 23, 2018, 7:26pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/10 "2018-03-23T19:26:20Z")

</div>

> no problem with the locally built extensions and the locally Slicer

Great

### summary

> problem is with the extensions built locally with the binary Slicer downloaded from Slicer website

Could you indicate which binary you downloaded (version of Slicer)

> I built Slicer in 2 different machines (Ubuntu 16). I got the same error. So probably there is something wrong with the source or there is something installed affect the build.

To clarify, you build locally Slicer on two different machine:

- local machine 1 (Ubuntu 16)
- local machine 2 (Ubuntu 16)

Then, you locally built your extension on machine 1 and created a package from it (using `make package`)

Finally, you copied the packaged created on machine 1 onto machine 2.

Installed the extension using the [install extension from file](https://www.slicer.org/wiki/Documentation/Nightly/SlicerApplication/ExtensionsManager#Installing_an_extension_without_network_connection)

And you see the error at startup on machine 2 ?

### questions

It may be useful to try running the application setting the `LD_DEBUG` env variable. See [https://linux.die.net/man/8/ld.so](https://linux.die.net/man/8/ld.so) and [The LD\_DEBUG environment variable | B. Nikolic Software and Computing Blog](http://www.bnikolic.co.uk/blog/linux-ld-debug.html)

Do you have itk locally installed on any of the machine ?

What is the value of `LD_LIBRARY_PATH` ? Do you have any custom `ld.conf` settings ? (see file `/etc/ld.so.conf` or directory `/etc/ld.so.conf.d/`)

### abi checker

> Is there a away to test the ABI incompatibility

This project could be useful, but I don’t think it will help yet: [Making sure you're not a bot!](https://sourceware.org/glibc/wiki/Testing/ABI_checker)

### moving forward

To help with reproducing build, we are currently transitioning our linux build to use:

> **[GitHub - dockbuild/dockbuild: Compiling environments in Docker images.](https://github.com/dockbuild/dockbuild)**
>
> Compiling environments in Docker images.

This will allow anyone to re-produce the build locally.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 23, 2018, 9:21pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/11 "2018-03-23T21:21:52Z")

</div>

@jcfr many thanks for your concern.

> Could you indicate which binary you downloaded (version of Slicer)

The stable version. [Slicer 4.8.1 r26813](https://download.slicer.org/bitstream/738960). I thought by building the source of the same revision in release mode, I will get a compatible build.

> To clarify …

Everything is as you mentioned expect I am trying to run the locally build extension using the downloaded binary above.

In each machine I did:

- build Slicer r26813 in release mode.
- build the extension in release mode using the same build and packaged it.
- downloaded Slicer 4.8.1 and install the plugin using “install from a file” method.
- When I run the extension the error “undefined symbol” appeared.

> Do you have itk locally installed on any of the machine ?

All the machines has ITK locally build and installed (in addition to the one in Slicer superbuild).

> It may be useful to try running the application setting the LD\_DEBUG env variable.

Running LD\_DEBUG=symbol ~/mySlicerBinaryPath/Slicer – launch ./my\_cli some\_argument 2\> LD\_DEBUG\_Output.txt produced thousands of lines, large part of the output is missing in the txt file.

> What is the value of LD\_LIBRARY\_PATH ?

$ echo $LD\_LIBRARY\_PATH  
:/usr/local/cuda-9.0/lib64:/usr/local/lib:~/sw/qt5.7.0/5.7/gcc\_64/lib

> Do you have any custom ld.conf settings ?

I think I don’t have any custom ld.conf setting.

> abi checker  
> moving forward, dockbuild - Compiling environments in Docker images.

This would be very nice to have.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 24, 2018, 8:15am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/12 "2018-03-24T08:15:11Z")

</div>

**Update:**

The problem is still there even after clean install of Ubuntu 16. I installed a new Ubuntu 16 in a virtualbox and run this script to build Slicer:

```
# Preare build tree 
mkdir ~/sw
mkdir ~/sw/Slicer4.8.1-dev
mkdir ~/sw/Slicer4.8.1-dev/build

# Install necessary tools 
sudo apt -y update && sudo apt upgrade && sudo apt-get install subversion git-core git-svn make gcc g++ libx11-dev libxt-dev libgl1-mesa-dev libglu1-mesa-dev libfontconfig-dev libxrender-dev libncurses5-dev curl libssl-dev  

#install qt4
sudo apt -y install qt4-dev-tools libqt4-dev libqtcore4 libqtgui4 libqtwebkit-dev

# Download and install CMake3.11
wget -N https://cmake.org/files/v3.11/cmake-3.11.0-rc4.tar.gz -P ~/sw && tar -xzvf ~/sw/cmake-3.11.0-rc4.tar.gz -C ~/sw

cd ~/sw/cmake-3.11.0-rc4
./bootstrap && make && sudo make install 

#Download build Slicer
cd ~/sw/
svn co http://svn.slicer.org/Slicer4/branches/Slicer-4-8 ~/sw/Slicer4.8.1-dev/src -r 26813 && 
cd ~/sw/Slicer4.8.1-dev/build
cmake -DCMAKE_BUILD_TYPE=Release ~/sw/Slicer4.8.1-dev/src && make 

```

I tried in two different Ubuntu 16 machines, their build are compatible with each other but not with the one from Slicer download:

- Machine 1 has M1Slicer-build (the build folder for Slicer) and M1Slicer-bin (the Slicer binary package generated from the build)
- Machine 2 has M2Slicer-build and M2Slicer-bin
- I copied M1Slicer-bin to Machine 2 and copied MSlicer-bin to Machine 1
- In Machine 1: I can build an extension using M1Slicer-build and install it and run it in the copied M1Slicer-bin
- Same goes for Machine 2.

Is there something I did wrong? does using cmake 3.11 make difference? or maybe Ubuntu 16 is not compatible with the Slicer Linux binary I downloaded?

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 27, 2018, 7:05pm UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/13 "2018-03-27T19:05:49Z")

</div>

**Update**  
Tried a Slicer build using [qt4t easy](https://github.com/jcfr/qt-easy-build). I tested after the build, still not compatible.

If anyone was able to build a compatible Slicer version in Ubuntu 16.04, I would like to know how he did it.

I think the source is not the same. I noticed there is a small change in the “about window” (one has the date in the second line while the other has not). As I have number of ITK extensions don’t work, probably the ITK version or the ITK configuration is different?

 ![SlicerBuild](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/3/d3963ac0fd58ad5c51c03a778b43847ef19c5396.png)

@jcfr @lassoan : could you please comment or suggest?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 29, 2018, 5:38am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/14 "2018-03-29T05:38:05Z")

</div>

> one has the date in the second line while the other has not

This is normal, to build a release that do not include the date, you would have to set the option `-DSlicer_RELEASE_TYPE:STRING=Stable`. See [ReleaseProcess](https://www.slicer.org/wiki/Documentation/Nightly/Developers/ReleaseProcess#Day_1:_Release) checklist.

But the impact is only cosmetic.

> If anyone was able to build a compatible Slicer

You can **not** build extension using Ubuntu 16.04 and expect them to be compatible with the Slicer 4.8.1 release.

Indeed, the Slicer 4.8.1 release was done using Ubuntu 10.04.

Considering it is not possible to install such an old distribution, there is we now docker images allowing to reproduce builds.

Following this guide will allow you to build your extension and have it working with the Slicer 4.8.1 Linux release.

See [Introducing SlicerBuildEnvironment project](https://discourse.slicer.org/t/introducing-slicerbuildenvironment-project/2465#heading--step-by-step-1)

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 29, 2018, 6:49am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/15 "2018-03-29T06:49:10Z")

</div>

> [@jcfr](#):
>
> ng Ubuntu 10.04.

Now I understand, thanks for the comment.

Why not using the last stable Ubuntu i.e. 16.04 instead of Ubuntu 10.04? with the script above, I was able to build Slicer without any problem in different machines including virtualbox machine. I will try the docker approach as well.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 29, 2018, 6:54am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/16 "2018-03-29T06:54:50Z")

</div>

> [@brhoom](#):
>
> Why not using the last stable Ubuntu i.e. 16.04 instead of Ubuntu 10.04?

To ensure the generated binaries can run a broad set of linux distribution, it is important to use an older distribution requiring an older version of GLIBC and GLIBCXX .

For the upcoming release depending on qt5, we will use centos7

> [@brhoom](#):
>
> . I will try the docker approach as well.

Great. Wait until tomorrow, updated images are being generated and should be available on dockerhub shortly. The current `ubuntu1004-gcc4` has gcc version 4.4.3 but Slicer binaries were generated with gcc 4.6. See [here](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Factory#factory-south-ubuntu.kitware)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 29, 2018, 9:05am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/17 "2018-03-29T09:05:18Z")

</div>

> [@jcfr](#):
>
> Wait until tomorrow, updated images are being generated

Updated docker images are now available.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [March 30, 2018, 11:20am UTC](https://discourse.slicer.org/t/undefined-symbol-when-run-my-cli-modules-extensions/2393/18 "2018-03-30T11:20:40Z")

</div>

I just tried it, it was some how complicated because I am trying to get the concept of the docker and there was was some problems regarding permissions and c++ code in my extensions but finally it works now 🙂 . Thanks for your effort.

I hope, I am not asking too much 😁 maybe in the future, it is much simpler if you provide an actual build of some popular Linux systems using the recent stable version as everything can be done automatically via scripting. Some download statistics can help in deciding this based on which operating systems the downloaders use.
