linux - g++ static link to libstdc++.a error -


my application can compiled & linked via gcc/g++ 4.4.7, shipped centos 6.5.

i wanna static link libstdc++.a via -static-libstdc++ , not supported 4.4.7. hence installed redhat-devtools-1.1 via following command, upgraded gcc/g++ 4.7.2

cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo  yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++ 

then compile application new toolset, fails

/opt/centos/devtoolset-1.1/root/usr/bin/c++ -m64   -c -o2 -iinc -fpic  -mmd -mp -mf "autoinit.o.d" -o autoinit.o autoinit.cpp /opt/centos/devtoolset-1.1/root/usr/bin/gcc   -m64   -c -o2 -d_largefile64_source=1 -iinc -std=c99 -fpic  -mmd -mp -mf "common.o.d" -o common.o common.c /opt/centos/devtoolset-1.1/root/usr/bin/gcc   -m64   -c -o2 -d_largefile64_source=1 -iinc -std=c99 -fpic  -mmd -mp -mf "rpc.o.d" -o rpc.o rpc.c /opt/centos/devtoolset-1.1/root/usr/bin/gcc   -m64   -c -o2 -d_largefile64_source=1 -iinc -std=c99 -fpic  -mmd -mp -mf "transport_service.o.d" -o transport_service.o transport_service.c /opt/centos/devtoolset-1.1/root/usr/bin/gcc   -m64   -c -o2 -d_largefile64_source=1 -iinc -std=c99 -fpic  -mmd -mp -mf "interop.o.d" -o interop.o interop.c /opt/centos/devtoolset-1.1/root/usr/bin/gcc   -m64   -c -o2 -d_largefile64_source=1 -iinc -std=c99 -fpic  -mmd -mp -mf "utility.o.d" -o utility.o utility.c /opt/centos/devtoolset-1.1/root/usr/bin/g++ -o libmq.so autoinit.o common.o rpc.o transport_service.o interop.o utility.o -l./lib -l:libapr-1.a -l:libcurl.a -l:libjansson.a -static-libgcc -static-libstdc++ -wl,--start-group -l:libzmq.a -l:libczmq.a -wl,--end-group -shared -fpic /usr/bin/ld: /opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/libstdc++.a(compatibility.o): relocation r_x86_64_32 against `_ztin10__cxxabiv115__forced_unwinde' can not used when making shared object; recompile -fpic /opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/libstdc++.a: not read symbols: bad value collect2: error: ld returned 1 exit status 

please know how resolve problem?

likely libstdc++.a compiled without -fpic ld prohibites building shared object it. http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/ . need recompile libstdc++.a yourself.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -