【发布时间】:2016-03-06 19:49:40
【问题描述】:
我很难弄清楚如何在我的 AIX 7.1 中添加 getopt.h。我在我的代码中使用了getopt_long 函数,我知道它在getopt.h 中而不是unistd.h 中(其中包含getopt())。
此代码未在 AIX 中编译:
fatal error: getopt.h: No such file or directory
#include <getopt.h>
^
compilation terminated.
这里是安装的 gcc 包:
gcc-4.8.3-1.aix7.1.ppc.rpm
gcc-c++-4.8.3-1.aix7.1.ppc.rpm
libgcc-4.8.3-1.aix7.1.ppc.rpm
gcc-cpp-4.8.3-1.aix7.1.ppc.rpm
我已经浏览了这些链接,但它们并没有太大帮助:
- http://www.ibm.com/developerworks/aix/library/au-unix-getopt.html#sthash.Loz3H0AH.dpuf
- http://www.linuxmisc.com/8-freebsd/eb9bdab1cf6044d5.htm
还有很多其他的网络搜索。
我是否缺少一些 rpm 或一些环境变量?
【问题讨论】:
-
我猜
getopt_long和getopt_long_only是 GNU 特定的函数,在 AIX 中可能不存在。 -
getopt_long是一个 GNU 函数。我不知道这是否有帮助,但在我的 Debian Linux 机器上,dlocate报告了libc6-dev:amd64: /usr/include/getopt.h- 即它是 GNU libc 的一部分。在最坏的情况下,您可能不得不求助于autoconf测试,并编写一个#ifdef,当它找不到getopt_long()时只允许短选项。
标签: c++ aix getopt-long