collect2:错误:ld 在制作带有代码块的 .so 文件(64 位版本)时返回 1 个退出状态
collect2: error: ld returned 1 exit status on making .so file with codeblocks (64 bit version)
我的问题是在代码块中制作.so文件,在旧版本(32位)中制作我的.so文件的项目失败,新版本(64位)中出现以下错误
/usr/bin/ld: obj/Debug/src/tester.o: relocation R_X86_64_PC32 against symbol `_ZTV6tester' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
代码块命令行
g++ -Wall -fexceptions -g -Iinclude -c /home/amini/codes/testr/main.cpp -o obj/Debug/main.o
g++ -Wall -fexceptions -g -Iinclude -c /home/amini/codes/testr/src/tester.cpp -o obj/Debug/src/tester.o
g++ -shared obj/Debug/main.o obj/Debug/src/tester.o -o bin/Debug/liblibTestso.so -m64 -fPIC
帮我解决这个问题,非常感谢
我看到很多关于此错误的链接,没有人清楚地回答我的问题当您从 32 位迁移到 64 位 Linux 系统代码块时,会出现上述错误
通过将 -fPIC 添加到编译器选项,问题无法解决,因为其他对象文件不使用该选项,那么您应该转到设置>编译器>其他设置>高级选项并在那里添加 -fPIC
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 导入库可以跨dll版本工作吗
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- Constexpr替代了新的放置方式,可以让内存中的对象保持未初始化状态
- 在clang++预处理器中确定gcc工具链版本
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- OSX MetalKit CVMetalTextureCacheCreateTextureFromImage失败,状态:
- 不同的Visual Studio版本中缺少.dll
- 用符号版本替换对函数的所有调用
- luaL_dofile在已知良好的字节码上失败,可以使用未编译的版本
- 正在解码MSVC 32位版本的程序集(作业).没有手术做什么
- std::future_error:无关联状态
- 我需要分发哪些版本的可再分发文件
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- 在运行时读取 libstdc++ 版本
- 如何声明一个可以在整个程序中使用的全局 2d 3d 4d .. 数组(堆版本)变量?
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- collect2:错误:ld 在制作带有代码块的 .so 文件(64 位版本)时返回 1 个退出状态
- 具有状态的Microsoft编译器版本19.16.27024.1的问题