How can I set ccshared=-fPIC while executing ./con

2019-03-11 02:30发布

I am trying to build Python 2.6 for QGIS on RHEL 5. During the making of QGIS I get the following error:

Linking CXX shared library libqgispython.so
/usr/bin/ld: /usr/local/lib/python2.6/config/libpython2.6.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.6/config/libpython2.6.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [src/python/libqgispython.so.1.0] Error 1
make[1]: *** [src/python/CMakeFiles/qgispython.dir/all] Error 2
make: *** [all] Error 2

What I figure out from this error is that I need to build Python 2.6 with some flag, -fPIC. OK, so I found it in the configure.in file but it checks several conditions and on the basis of those conditions it assigns -fPIC to the CCSHARED flag.

What I did was that after all conditions were checked I added the following line to deliberately use CCSHARED as -fPIC.

CCSHARED="-fPIC";

But it did not work..

How to specify while configuring that I want to set CCSHARED as -fPIC?

标签: c++ makefile g++
8条回答
相关推荐>>
2楼-- · 2019-03-11 02:32

rebuilt the openssl with ./config --prefix=/software/bea/openssl/100c --openssldir=/software/bea/openssl/100c/ssl shared -fPIC

and then also it dint work. it gave /usr/bin/ld: links failed. The we modifed the linking part in make file previously it was gcc -Wall -shared -o pwutil.so asciihex.o base64.o bitutils.o dict.o gen_rand.o key_schedule.o md5c.o pdg2_ecb.o pwutils.o random_data.o hexutils.o des3crypt.o blowcrypt.o /software/bea/openssl/1.0.0c/lib/libcrypto.a

we changed libcrypto.a to libcrypto.so after rebuilding with shared option and - fPIC

gcc -Wall -shared -o pwutil.so asciihex.o base64.o bitutils.o dict.o gen_rand.o key_schedule.o md5c.o pdg2_ecb.o pwutils.o random_data.o hexutils.o des3crypt.o blowcrypt.o /software/bea/openssl/1.0.0c/lib/libcrypto.so

and it worked

查看更多
ら.Afraid
3楼-- · 2019-03-11 02:33

The following worked for me when I ran into this error:

make clean
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC
查看更多
虎瘦雄心在
4楼-- · 2019-03-11 02:36

The following has an example of passing fPIC to configure

查看更多
【Aperson】
5楼-- · 2019-03-11 02:43

I got it working by adding -fPIC after CC= gcc -pthread, i.e CC= gcc -pthread -fPIC in the Makefile.

查看更多
戒情不戒烟
6楼-- · 2019-03-11 02:48

Isn't that CCFLAGS? (Haven't been that side of the world for a while.)

查看更多
趁早两清
7楼-- · 2019-03-11 02:49

As noted elsewhere, running configure with --enable-shared should cause -fPIC to be included in the compiler flags. However, you may still see the "could not read symbols" error if you attempt to do a parallel build using, e.g., 'make -j8'. I had this same error on RHEL 5.2 and it only went away when I removed the '-j8' from my make invocation...

查看更多
登录 后发表回答