# Make fail: recompile with -fpic

**URL:** <https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86>\
**Category:** Installation\
**Created:** [March 13, 2020, 6:56am UTC](https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86 "2020-03-13T06:56:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sjter](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@Sjter](https://discourse.channelflow.ch/u/Sjter)\
**Post date:** [March 13, 2020, 6:56am UTC](https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86/1 "2020-03-13T06:56:01Z")

</div>

Hi, I am having difficulties installing channelflow. I’ve used the cmake command to build the makefile and instalation files, however when i run make -j it returns an error related to linking static and dynamic libraries:

/usr/bin/ld: /usr/local/lib/libfftw3\_mpi.a(api.o): relocation R\_X86\_64\_32S against `ompi\_mpi\_comm\_null’ can not be used when making a shared object; recompile with -fPIC  
/usr/local/lib/libfftw3\_mpi.a: error adding symbols: Bad value  
collect2: error: ld returned 1 exit status  
channelflow/CMakeFiles/chflow.dir/build.make:653: recipe for target ‘channelflow/libchflow.so’ failed  
make[2]: \*\*\* [channelflow/libchflow.so] Error 1  
CMakeFiles/Makefile2:384: recipe for target ‘channelflow/CMakeFiles/chflow.dir/all’ failed  
make[1]: \*\*\* [channelflow/CMakeFiles/chflow.dir/all] Error 2  
Makefile:138: recipe for target ‘all’ failed  
make: \*\*\* [all] Error 2

The compiler reccomends i include the -fPIC command, however I can’t find a way to modify either the makefile, or the cmake commands to do this.

I’ve also tried using -DWITH\_STATIC=ON and -DWITH\_SHARED=OFF to only create static libraries, but that didn’t seem to work. Heres the output of that command:

## sjter1@MU00140044L:~/Cbuild$ cmake …/channelflow -DCMAKE\_BUILD\_TYPE=release -DUSE\_MPI=ON -DWITH\_STATIC=ON -DWITH\_SHARED=OFF -DWITH\_HDF5CXX=ON

## – configuring channelflow version 2.0.2 – Using GNU compiler options

## – Starting system introspection – Found FFTW – FFTW\_LIBRARY=/usr/local/lib/libfftw3.a – FFTW\_OMP\_LIBRARY=/usr/lib/x86\_64-linux-gnu/libfftw3\_omp.a – FFTW\_MPI\_LIBRARY=/usr/local/lib/libfftw3\_mpi.a – MPI libs: /usr/lib/openmpi/lib/libmpi\_cxx.so;/usr/lib/openmpi/lib/libmpi.so – FFTW\_MPI library: /usr/local/lib/libfftw3\_mpi.a – NetCDF include dir: /usr/include – Checking if hdf5 library functions in are working correctly.

– Include directories:  
– Git revision 9f099a4079b8ffe8b22128afc4f6b02bae9a0b7f  
– Could NOT find Doxygen (missing: DOXYGEN\_EXECUTABLE)

###############################################  
########### Configuration summary ###########  
###############################################  
Compiler: GNU 5.4.0  
Build type: release  
Install prefix: /usr/local  
Building shared library: yes  
Linking programs to: shared library

Libraries  
MPI: enabled  
netcdf (default file format): enabled  
Parallel netcdf: disabled  
HDF5 C++ (legacy file format): enabled

Channelflow components  
nsolver: enabled  
Python wrapper: disabled  
GTest unit testing: enabled

– Configuring done  
– Generating done  
– Build files have been written to: /home/sjter1/Cbuild

Any idea what I can do to fix this?

---

<div class="post-metadata">

**Author:** ![jlangham](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jlangham](https://discourse.channelflow.ch/u/jlangham)\
**Post date:** [March 14, 2020, 11:47am UTC](https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86/2 "2020-03-14T11:47:47Z")

</div>

Hi,

To give flags to the compiler you can add something like

```
-DCMAKE_BUILD_TYPE=release -DCMAKE_CXX_FLAGS_RELEASE:STRING="-fPIC"

```

to your cmake call. I don’t know if that will fix it though necessarily. I usually find that these sorts of linker problems can be fixed trying different versions of libfftw3 and mpi (and sometimes gcc). If you’re on HPC see if you can swap out some different modules. Not a very intelligent solution but it can work!

Maybe someone else can add some more insight. You might also check to see if it compiles and links successfully in serial mode too.

---

<div class="post-metadata">

**Author:** ![chihin](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.channelflow.ch/chihin/32/26_2.png) [@chihin](https://discourse.channelflow.ch/u/chihin)\
**Post date:** [May 15, 2020, 4:02pm UTC](https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86/3 "2020-05-15T16:02:54Z")

</div>

I this is an old post but I still wish to bump it up as I had the same issues which i fixed. I reinstalled my all my fftw libraries from statically compiled (.a files) to dynamically compiled (.so files) and manage to get pass this error

---

<div class="post-metadata">

**Author:** ![zongzz](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zongzz](https://discourse.channelflow.ch/u/zongzz)\
**Post date:** [November 18, 2022, 10:10pm UTC](https://discourse.channelflow.ch/t/make-fail-recompile-with-fpic/86/4 "2022-11-18T22:10:42Z")

</div>

To be more specific, configure fftw with `--enable-shared`
