# .rodata can not be used when making a PIE object

**URL:** <https://discourse.slicer.org/t/rodata-can-not-be-used-when-making-a-pie-object/6313>\
**Category:** Development\
**Tags:** build\
**Created:** [March 28, 2019, 2:59am UTC](https://discourse.slicer.org/t/rodata-can-not-be-used-when-making-a-pie-object/6313 "2019-03-28T02:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhiy](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@Zhiy](https://discourse.slicer.org/u/Zhiy)\
**Post date:** [March 28, 2019, 2:59am UTC](https://discourse.slicer.org/t/rodata-can-not-be-used-when-making-a-pie-object/6313/1 "2019-03-28T02:59:49Z")

</div>

Hi,

I am building Slicer in ubuntu 18.04. I followed every step in [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build\_Instructions#Linux](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions#Linux). But now I run into a build error: /usr/bin/ld: CMakeFiles/vtkParseJava.dir/vtkParseJava.c.o: relocation R\_X86\_64\_32 against .rodata can not be used when making a PIE object; recompile with -fPIC.  
/usr/bin/ld: …/…/lib/libvtkWrappingTools-8.2.a(vtkParseMain.c.o): relocation R\_X86\_64\_32 against `.rodata’ can not be used when making a PIE object; recompile with -fPIC  
…

My environment is:  
gcc/g++ 7.3, qt5.12, cmake 3.14, python 2.17.

My cmake command is  
cmake -DCMAKE\_BUILD\_TYPE:STRING=Debug -DQt5\_DIR:PATH=/home/me/Qt/5.12.0/gcc\_64/lib/cmake/Qt5 -DSlicer\_USE\_SYSTEM\_QT:BOOL=1 -DQT\_QMAKE\_EXECUTABLE=/home/me/Qt/5.12.0/gcc\_64/bin/qmake …/Slicer

Could anyone please help me out? I tried to add -fPIC in CMakeLists.txt as this post, [https://stackoverflow.com/questions/19364969/compilation-fails-with-relocation-r-x86-64-32-against-rodata-str1-8-can-not](https://stackoverflow.com/questions/19364969/compilation-fails-with-relocation-r-x86-64-32-against-rodata-str1-8-can-not). But it still doesn’t work.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![phcerdan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/phcerdan/32/1559_2.png) [@phcerdan](https://discourse.slicer.org/u/phcerdan)\
**Post date:** [March 28, 2019, 3:37am UTC](https://discourse.slicer.org/t/rodata-can-not-be-used-when-making-a-pie-object/6313/2 "2019-03-28T03:37:57Z")

</div>

Hi @Zhiy,

I would try first with a clean build directory.  
the errors show `libvtkWrappingTools-8.2.a`, which is a static library, when the default option in Slicer is to `BUILD_SHARED_LIBS:BOOL=ON` but that doesn’t correspond to the CMake options you posted.

Also, `QT_QMAKE_EXECUTABLE` is a Qt4 option, so you don’t need it.

Clean the build folder (the whole folder, not only the subfolder Slicer-build)  
And then try with:

```bash
cmake -DCMAKE_BUILD_TYPE:STRING=Debug \
-DQt5_DIR:PATH=/home/me/Qt/5.12.0/gcc_64/lib/cmake/Qt5 \
-DSlicer_USE_SYSTEM_QT:BOOL=1 \
../Slicer

```

This is just a first aid intuition. Let us know if you still hit the problem after that!

---

<div class="post-metadata">

**Author:** ![Zhiy](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@Zhiy](https://discourse.slicer.org/u/Zhiy)\
**Post date:** [March 28, 2019, 4:46pm UTC](https://discourse.slicer.org/t/rodata-can-not-be-used-when-making-a-pie-object/6313/3 "2019-03-28T16:46:55Z")

</div>

It solves my problem, except that I also followed the solution of makedev problem in this post: [Building failure on Ubuntu](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/10). Thank you a lot.
