# cmpiling ITK on CentOs - pcre/swig error

**URL:** <https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673>\
**Category:** Beginner Questions\
**Created:** [December 3, 2020, 10:23am UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673 "2020-12-03T10:23:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaron](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/53a042/32.png) [@Yaron](https://discourse.itk.org/u/Yaron)\
**Post date:** [December 3, 2020, 10:23am UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/1 "2020-12-03T10:23:51Z")

</div>

Hello,

I am trying to compile ITK on a CentOs 7 cluster. During the compilation, I get the error -  
[56%] Completed ‘PCRE’  
[56%] Built target PCRE  
…  
[56%] No update step for ‘swig’  
[56%] No patch step for ‘swig’  
[56%] Performing configure step for ‘swig’  
– Swig configure successfully completed.  
[56%] Performing build step for ‘swig’  
Swig/misc.o: In function `Swig_string_regex': misc.c:(.text+0x2223): undefined reference to `pcre\_free’  
misc.c:(.text+0x22b7): undefined reference to `pcre_compile' misc.c:(.text+0x22f6): undefined reference to `pcre\_exec’  
misc.c:(.text+0x2334): undefined reference to `pcre_free' Swig/misc.o: In function `Swig\_pcre\_version’:  
misc.c:(.text+0x2405): undefined reference to `pcre_version' Swig/naming.o: In function `name\_regexmatch\_value’:  
naming.c:(.text+0x32): undefined reference to `pcre_compile' naming.c:(.text+0x77): undefined reference to `pcre\_exec’  
naming.c:(.text+0x83): undefined reference to `pcre\_free’  
collect2: error: ld returned 1 exit status  
make[5]: \*\*\* [eswig] Error 1  
make[4]: \*\*\* [all] Error 2  
make[3]: \*\*\* [source] Error 2  
make[2]: \*\*\* [Wrapping/Generators/SwigInterface/swig-prefix/src/swig-stamp/swig-build] Error 2  
make[1]: \*\*\* [Wrapping/Generators/SwigInterface/CMakeFiles/swig.dir/all] Error 2  
make: \*\*\* [all] Error 2

Is the swig needed? Can I skip it by choosing some option in the configure step? how do I get over the problem that it does not recognize pcre even after it was compiled during the build process?

Best,  
Yaron

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [December 3, 2020, 6:17pm UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/2 "2020-12-03T18:17:58Z")

</div>

Which version of ITK are you trying to compile? `pcre_free` problem sounds familiar.

---

<div class="post-metadata">

**Author:** ![Yaron](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/53a042/32.png) [@Yaron](https://discourse.itk.org/u/Yaron)\
**Post date:** [December 3, 2020, 7:31pm UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/3 "2020-12-03T19:31:16Z")

</div>

InsightToolkit-5.1.1

Yes, I read that people had it on MacOs, and there was a solution, but I am building on Linux CentOs 7.

Yaron

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [December 9, 2020, 5:01pm UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/4 "2020-12-09T17:01:55Z")

</div>

Welcome to the ITK community @Yaron! ☀

There should not be any issues with the CentOS 7 build – I built it yesterday :-).

Are any SWIG-related CMake options changed from their default? What are the CMake configuration options changed from the defaults?

---

<div class="post-metadata">

**Author:** ![Yaron](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/53a042/32.png) [@Yaron](https://discourse.itk.org/u/Yaron)\
**Post date:** [December 10, 2020, 8:49am UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/5 "2020-12-10T08:49:39Z")

</div>

Dear Matt,

Thanks for your answer.  
I think I found the error. Yesterday, I built InsightToolkit-5.1.2 with the default configuration and it worked.

However, if I tried to activate the building of examples (BUILD\_EXAMPLES), the python wrapper (ITK\_WRAP\_PYTHON), and the Module\_SimpleITKFilters it fails with the same error about swig and PCRE.

The reason is that I try to install InsightToolkit on a CentOs Cluster. I do not have an administer privileges so I install it in an alternative path (to be used later on using the module package of clusters computational gridI).

After configuration, I use the command: make DESTDIR=PATH\_TO\_INSTALL install

As a result, make creates the following folders:

A. PATH\_TO\_INSTALL/usr

B. PATH\_TO\_INSTALL/ORIGINAL\_PATH\_OF\_BINARIES\_BUILD/Wrapping/Generators/SwigInterface/PCRE/

In the first, it places all the ITK compiles files, and in the second the PCRE.

So, when one of BUILD\_EXAMPLES, ITK\_WRAP\_PYTHON, or module\_SimpleITKFilters needs swig (I do not know which one), it does not find it due to the additional ORIGINAL\_PATH\_OF\_BINARIES\_BUILD created by cmake.

In conclusion, there is an error in the cmake file regarding the way that it install PCRE in an alternative path.

Yaron

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [December 10, 2020, 9:56pm UTC](https://discourse.itk.org/t/cmpiling-itk-on-centos-pcre-swig-error/3673/6 "2020-12-10T21:56:59Z")

</div>

Dear Yaron,

Thanks for the update.

Could you please try disabling `Module_SimpleITKFilters` then, installing to an alternative path.

If the behavior is the same, please try disabling `ITK_WRAP_PYTHON`, then installing to an alternative path.

Either of those may be building SWIG / PCRE, but SWIG / PCRE should not be installed into the install tree.

Thanks,  
Matt
