gpt4 book ai didi

c++ - 什么是 -fPIC 编译选项?

转载 作者:太空宇宙 更新时间:2023-11-04 14:39:23 25 4
gpt4 key购买 nike

今天,当尝试使用 mongodb c++ 客户端构建我的 so lib 项目时,出现错误:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libmongoclient.a(connection_factory.o): relocation R_X86_64_32S against `_ZTVN5mongo17AScopedConnectionE' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libmongoclient.a: error adding symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我用谷歌搜索了 -fPIC,但一无所获。我在哪里可以找到关于这个的文档?这是什么?我正在使用 clang++ 进行构建。

最佳答案

PIC 代表位置独立代码。引用自 man gcc:

If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table.

关于c++ - 什么是 -fPIC 编译选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20464234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com