如何在执行 ./configure 时设置 ccshared=-fPIC?
我正在尝试为 QGIS 构建 Python 2.6。 wikipedia.org/wiki/Red_Hat_Enterprise_Linux" rel="noreferrer">RHEL 5. 在制作 QGIS 的过程中,我收到以下错误:
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
从这个错误中我发现我需要使用一些标志 -fPIC
来构建 Python 2.6。 好的,我在 configure.in
文件中找到了它,但它检查了几个条件,并根据这些条件将 -fPIC
分配给 CCSHARED 标志。
我所做的是,在检查了所有条件后,我添加了以下行,故意将 CCSHARED 用作 -fPIC
。
CCSHARED="-fPIC";
但它不起作用..
如何在配置时指定我要将CCSHARED
设置为-fPIC
?
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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如其他地方所述,使用 --enable-shared 运行配置应该会导致 -fPIC 包含在编译器标志中。 但是,如果您尝试使用“make -j8”等进行并行构建,您可能仍然会看到“无法读取符号”错误。 我在 RHEL 5.2 上遇到了同样的错误,只有当我从 make 调用中删除“-j8”时,它才消失......
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...
这不是
CCFLAGS
吗? (有一段时间没去过世界的那一边了。)Isn't that
CCFLAGS
? (Haven't been that side of the world for a while.)重建 openssl 与
./config --prefix=/software/bea/openssl/100c --openssldir=/software/bea/openssl/100c/ssl共享-fPIC
然后它也不起作用。 它给出了 /usr/bin/ld: 链接失败。
我们修改了make文件中的链接部分
以前是 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 sellcrypt .o /software/bea/openssl/1.0.0c/lib/libcrypto.a
重建后,我们将 libcrypto.a 更改为 libcrypto.so。
在使用共享选项和 - 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
它起作用了
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
以下是传递 fPIC 进行配置的 示例
The following has an example of passing fPIC to configure
我让它与:
I got it working with:
使用
--enable-shared
运行配置。 然后 -fPIC 将作为共享标志的一部分包含在内。Run configure with
--enable-shared
. Then-fPIC
will be included as part of the shared flags.当我遇到此错误时,以下内容对我有用:
The following worked for me when I ran into this error:
我通过在
CC= gcc -pthread
之后添加-fPIC
使其工作,即Makefile 中的
CC= gcc -pthread -fPIC
。I got it working by adding
-fPIC
afterCC= gcc -pthread
,i.e
CC= gcc -pthread -fPIC
in the Makefile../configure --help
,可能通过管道连接到 grep PIC,以查看是否有启用此选项的选项。如果这些都不起作用,您需要阅读配置代码并更好地理解它测试的条件。
./configure --help
, possibly piping to grep PIC, to see if there's an option to enable thisIf neither of those work, you need to read the configure code and understand the conditions it tests for better.