I built my own gcc from source using
/configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-6.4 --prefix=/home/martin/devel/gcc-6.4.0-build
make
Everything went well except when I want to build my shared library with static runtime using cmake like this:
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_C_COMPILER /home/martin/devel/gcc-6.4.0-build/bin/gcc-6.4)
SET(CMAKE_CXX_COMPILER /home/martin/devel/gcc-6.4.0-build/bin/g++-6.4)
project(Foo)
add_library(FooLib SHARED main.cpp)
target_link_libraries(FooLib -static-libgcc -static-libstdc++ -static)
When I try to make this I get the following error:
/usr/bin/ld: /home/martin/devel/gcc-6.4.0-build/lib/gcc/x86_64-linux-gnu/6.4.0/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
/home/martin/devel/gcc-6.4.0-build/lib/gcc/x86_64-linux-gnu/6.4.0/crtbeginT.o: error adding symbols: Bad value
So I suspected that the gcc wasn't been built properly, don't know how to do that.