沈天真
作者沈天真·2022-01-26 14:22
售前支持·IPS

AIX 7.2 上 gcc 编译 qt库报错

字数 963阅读 2198评论 0赞 0

最近在将ISV的应用从 Itanium+HP-UX 迁移到 K1 Power+AIX 7.2 上遇到的问题,分享一下。

问题现象

在AIX 7.2 上用 gcc 编译 libqt 时,报错

 codecs/qgb18030codec.cpp: In member function 'virtual QCString QGb2312Codec::fromUnicode(const QString&, int&) const’:    
 codecs/qgb18030codec.cpp:799:10: error: 'class QCString' has no member named 'truncate64'; did you mean 'truncate'?      
 rstr.truncate(lenInOut);           
 ^

定位过程

查看 AIX 7.2 上的官方文档

https://www.ibm.com/docs/en/aix/7.2?topic=t-truncate-truncate64-ftruncate-ftruncate64-subroutine

发现 truncate / truncate64 定义在头文件 unistd.h 中

通过查找文件 unistd.h ,发现在 gcc 中,在路径

/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/unistd.h 包含了一个 unistd.h

其中,有如下的定义

#ifdef _LARGE_FILES
#define ftruncate       ftruncate64 
#define truncate        truncate64 
#endif

因为 AIX 7.2 有大文件支持,此时把 truncate 定义为了 truncate64 ,但是 libqt 使用的类 QCString 中使用的还是 truncate ,没有 truncate64 ,导致错误。主要是ISV应用开发很早,使用的qt版本比较老了。

解决方法

将_LARGE_FILES 时定义先注释掉,重新编译。

另外,建议尽可能使用AIX 7.2 上支持的最新版本的qt库。

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广