我正在使用 g++ 并使用 -fPIC 选项编译 C++ 静态库。我必须使用 -fPIC 选项,因为最终该库将与其他静态库链接以形成动态库。
当我在本地测试静态库时,当我不包含 -fPIC 选项时,它完全正常工作。但是,只要我使用 -fPIC 编译库,在运行时调用其中一个函数时就会收到分段错误错误。
包含 -fPIC 编译静态库的原因可能会导致运行时出现分段错误?
c++ compilation shared-libraries static-libraries fpic
c++ ×1
compilation ×1
fpic ×1
shared-libraries ×1
static-libraries ×1