在c++程序中用g++链接32位和64位.so文件
Linking both 32bit and 64bit .so files with g++ for a c++ program
我试图同时链接32位和64位。so文件用于c++程序。我使用的是64位Ubuntu 12.04.1,我也没有源文件可以重新编译。
当我运行g++命令时:
<>之前g++ onlintraining .cpp -I/usr/local/matlab/r2012a_student/extern/include/-L/home/forest/soarsuite/out/-L/usr/local/matlab/r2012a_student/bin/glnx86/-I/home/forest/soarsuite/out/include -leng -lmat -lmex -lut -lSoar之前我得到以下输出,因为它不识别32位的。so文件:
<>之前/usr/bin/ld:跳过不兼容的/usr/local/matlab/r2012a_student/bin/glnx86//libeng。所以当搜索- length时/usr/bin/ld:找不到- length/usr/bin/ld:跳过不兼容的/usr/local/matlab/r2012a_student/bin/glnx86//libmat。所以当搜索-lmat时/usr/bin/ld:无法找到-lmat/usr/bin/ld:跳过不兼容的/usr/local/matlab/r2012a_student/bin/glnx86//libmex。所以当搜索-lmex时/usr/bin/ld:找不到-lmex/usr/bin/ld:跳过不兼容的/usr/local/matlab/r2012a_student/bin/glnx86//libut。所以当搜索-lut时/usr/bin/ld:找不到-lutCollect2: ld返回1退出状态之前当我用-m32运行g++命令时:
<>之前g++ -m32 onlintraining .cpp -I/usr/local/matlab/r2012a_student/extern/include/-L/home/forest/soarsuite/out/-L/usr/local/matlab/r2012a_student/bin/glnx86/-I/home/forest/soarsuite/out/include -leng -lmat -lmex -lut -lSoar之前我得到以下输出,因为现在它不识别64位的。so文件:
<>之前/usr/bin/ld:跳过不兼容的/home/forest/soarsuite/out//libSoar。所以当搜索-lSoar时/usr/bin/ld:找不到-lSoar/usr/bin/ld:跳过不兼容的/usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++。所以当搜索-lstdc++时/usr/bin/ld:跳过不兼容的/usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++。当搜索-lstdc++时/usr/bin/ld:找不到-lstdc++Collect2: ld返回1退出状态之前是否可以同时链接34bit和64bit .so文件?谢谢你。
不,这不可能。32位库只能链接到32位可执行文件中,64位库只能链接到64位可执行文件中。
如果您试图链接的Matlab库仅作为32位可用,则您需要将应用程序构建为32位(使用-m32
),并且仅链接32位库。
我建议制作一个shell脚本或制作一个文件来运行这两个编译器命令。
相关文章:
- 将应用程序从32位移植到64位时出现问题
- qmake:检测目标位宽(32 位或 64 位)
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 浮点数为 32 位和 64 位二进制表示形式
- 如何在 64 位平台上计算 32 位哈希C++?
- 制定目标需要32和64位的DLL构建
- 在32、64位正确存储容器大小
- 如何将 32 位有符号整数放入更高的 32 位 64 位无符号整数中
- 与同时32和64位客户端同时使用Process COM服务器
- C++使用 MSI 自动化 API 32 和 64 位的应用程序
- 算法C/C++:用n和d 32或64位整数计算(2^n)%d的最快方法
- 32位- 64位进程间通信
- visual c++ Windows Shell Extensions - Win7 32位- 64位兼容性问题
- 如何在运行的C++/Qt应用程序中检测底层Windows是否为32或64位版本
- 正确(独立于32位/64位)将浮点数保存为二进制流
- 32 位 64 位 - 警告:右移计数 >= 32 位计算机上的类型宽度
- 澄清:移植32到64位
- 使用C++检测Windows体系结构(32或64位)-wProcessorArchitecture显示错误的结果
- 如何编写可转换代码,32位/64位
- c++:如何在Windows 32和64位获取最新的Java路径