如何在执行 ./configure 时设置 ccshared=-fPIC?

发布于 2024-07-14 17:51:22 字数 1100 浏览 2 评论 0原文

我正在尝试为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

寻找一个思念的角度 2024-07-21 17:51:23

如其他地方所述,使用 --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...

暮色兮凉城 2024-07-21 17:51:23

这不是CCFLAGS吗? (有一段时间没去过世界的那一边了。)

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

小鸟爱天空丶 2024-07-21 17:51:23

重建 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

第七度阳光i 2024-07-21 17:51:23

以下是传递 fPIC 进行配置的 示例

The following has an example of passing fPIC to configure

仅一夜美梦 2024-07-21 17:51:23

我让它与:

./configure --enable-shared --enable-pic

I got it working with:

./configure --enable-shared --enable-pic
榕城若虚 2024-07-21 17:51:22

使用 --enable-shared 运行配置。 然后 -fPIC 将作为共享标志的一部分包含在内。

Run configure with --enable-shared. Then -fPIC will be included as part of the shared flags.

盗琴音 2024-07-21 17:51:22

当我遇到此错误时,以下内容对我有用:

make clean
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC

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

make clean
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC
辞取 2024-07-21 17:51:22

我通过在 CC= gcc -pthread 之后添加 -fPIC 使其工作,
即Makefile 中的CC= gcc -pthread -fPIC

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

她比我温柔 2024-07-21 17:51:22
  1. 运行 ./configure --help,可能通过管道连接到 grep PIC,以查看是否有启用此选项的选项。
  2. 尝试在运行配置之前设置环境变量,例如 CCSHARED="-fPIC" ./configure (作为单个命令,假设是 bash)

如果这些都不起作用,您需要阅读配置代码并更好地理解它测试的条件。

  1. Run ./configure --help, possibly piping to grep PIC, to see if there's an option to enable this
  2. Try setting the environment variable before running configure, e.g. CCSHARED="-fPIC" ./configure (as a single command, assuming bash)

If neither of those work, you need to read the configure code and understand the conditions it tests for better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文