External Email - Use Caution        

​Hello Christian,

To build Freesurfer e.g., on CentOS7, we use rev 4.8.5 of gcc, g++ and gfortran.  You can tell cmake what compilers to use on the command line with CC=<path>/gcc  CXX=<path>/g++  FC=<path>/gfortran  If you need to specify the gfortran library to use, you can set it with -DGFORTRAN_LIBRARIES=<path to gfortran's lib>/libgfortran.a

On Ubuntu 16, the native /usr/bin/gcc is rev 5.4.0, so I installed the gcc 4.9 compilers, and set the above to CC=/usr/bin/gcc-4.9, CXX=/usr/bin/g++-4.9, FC=/usr/bin/gfortran-4.9.  You could try doing the same on Ubuntu 18 as the native gcc may be rev 5.4 or newer, and I don't believe gcc rev 5 will work to build freesurfer.



On Oct 31, 2018, at 23:13, Christian Lee Mcdaniel <clm121@uga.edu> wrote:

        External Email - Use Caution        
Hi there,

Thank you for directing me to the CMake fswiki. I was able to install the third party packages and execute the command `cmake . -DFS_PACKAGES_DIR="path/to/pkgs"`. 

However, when I run `make -j4` (after adjusting a few bash files in various libraries to find (#include) other libraries) I am met with numerous similarly-worded link error lines under the step "Linking Fortran executable t4imgs_4dfp" with the general schema:

/usr/bin/ld: path/to/fortran-related/filename: relocation R_X86_64_32 against `some.variable.or.file.name` can not be used when making a PIE object; recompile with -fPIC

where path/to/fortran-related/filename is either CMakeFiles/t4imgs_4dfp.dir/some-file.c.o or /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.a(some-function.o)

I tried finding a solution online and found the suggestion to add a global -fPIC flag via export CXXFLAGS="$CXXFLAGS -fPIC" (https://stackoverflow.com/questions/13812185/how-to-recompile-with-fpic). I tried this by starting completely over with a new clone of the freesurfer repo and calling cmake . -DFS_PACKAGES_DIR="path/to/pkgs" and the make still failed at the same point. 

Other suggestions (e.g., to add --enable-shared at ./configure(in that same thread linked above)) suggest adding arguments when configuring, but since this is all part of the make process I'm not sure whether that's possible. 

Any advice? I did not find any similar issues in the archive. 

Thank you very much,
Christian McDaniel






On Oct 31, 2018, at 23:13, Christian Lee Mcdaniel <clm121@uga.edu> wrote:

        External Email - Use Caution        
Hi there,

Thank you for directing me to the CMake fswiki. I was able to install the third party packages and execute the command `cmake . -DFS_PACKAGES_DIR="path/to/pkgs"`. 

However, when I run `make -j4` (after adjusting a few bash files in various libraries to find (#include) other libraries) I am met with numerous similarly-worded link error lines under the step "Linking Fortran executable t4imgs_4dfp" with the general schema:

/usr/bin/ld: path/to/fortran-related/filename: relocation R_X86_64_32 against `some.variable.or.file.name` can not be used when making a PIE object; recompile with -fPIC

where path/to/fortran-related/filename is either CMakeFiles/t4imgs_4dfp.dir/some-file.c.o or /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.a(some-function.o)

I tried finding a solution online and found the suggestion to add a global -fPIC flag via export CXXFLAGS="$CXXFLAGS -fPIC" (https://stackoverflow.com/questions/13812185/how-to-recompile-with-fpic). I tried this by starting completely over with a new clone of the freesurfer repo and calling cmake . -DFS_PACKAGES_DIR="path/to/pkgs" and the make still failed at the same point. 

Other suggestions (e.g., to add --enable-shared at ./configure(in that same thread linked above)) suggest adding arguments when configuring, but since this is all part of the make process I'm not sure whether that's possible. 

Any advice? I did not find any similar issues in the archive. 

Thank you very much,
Christian McDaniel