MacOS X 10.6 下 编译APUE代码清单(apue.2e 第二版源码)
2012-08-09 19:37
627 查看
1、修改文件Make.defines.macos设置代码目录变量,将WKDIR值改为实际代码目录
$ vim Make.defines.macos
2、修改WKDIR/include/apue.h文件的6-11行如下所示,增加MACOS判断,如果不修改文件,
则定义_XOPEN_SOURCE为600,在macOS中头文件中,部分文件依据_XOPEN_SOURCE是否定义,来定义宏。
#if defined(SOLARIS)
#define _XOPEN_SOURCE 500 /* Single UNIX Specification, Version 2 for Solaris 9 */
#define CMSG_LEN(x) _CMSG_DATA_ALIGN(sizeof(struct cmsghdr)+(x))
#elif defined(MACOS) /*增加的*/
#elif !defined(BSD)
#define _XOPEN_SOURCE 600 /* Single UNIX Specification, Version 3 */
#endif
3、在WKDIR下,编译即可。
$ make
(注:Mac OS X 10.6.8系统,APUE代码是《UNIX环境高级编程(第二版)》,解压后为apue.2e文件夹)
在之前编译时,遇到过CMSG_LEN未定义的问题,根据http://www.apuebook.com/上的FAQs第10条,将CMSG_LEN的定义从系统include文件中找到了CMSG_LEN,在apue.h加了CMSG_LEN的定义,可以编译通过,但是接下来又遇到问题:
loop.c里的error: ‘fd_set’ undeclared。
fd_set是一个struct,将#include <sys/select.h>加进来可以解决问题。
但是紧接着又有major与minor宏未定义的问题,也可以通过查找macOS的/usr/include下grep查找找到头文件解决问题。
根据文章上面写的方法,就没有定义_XOPEN_SOURCE了。也就不遵循标准了?
查了一下关于_XOPEN_SOURCE
it tells your compiler to include definitions for some extra functions that are defined in the X/Open and POSIX standards.
This will give you some extra functionality that exists on most recent UNIX/BSD/Linux systems, but probably doesn't exist on other systems such as Windows.
The numbers refer to different versions of the standard.
500 - X/Open 5, incorporating POSIX 1995
600 - X/Open 6, incorporating POSIX 2004
700 - X/Open 7, incorporating POSIX 2008
具体的作用还得有时间再摸索摸索。
$ vim Make.defines.macos
2、修改WKDIR/include/apue.h文件的6-11行如下所示,增加MACOS判断,如果不修改文件,
则定义_XOPEN_SOURCE为600,在macOS中头文件中,部分文件依据_XOPEN_SOURCE是否定义,来定义宏。
#if defined(SOLARIS)
#define _XOPEN_SOURCE 500 /* Single UNIX Specification, Version 2 for Solaris 9 */
#define CMSG_LEN(x) _CMSG_DATA_ALIGN(sizeof(struct cmsghdr)+(x))
#elif defined(MACOS) /*增加的*/
#elif !defined(BSD)
#define _XOPEN_SOURCE 600 /* Single UNIX Specification, Version 3 */
#endif
3、在WKDIR下,编译即可。
$ make
(注:Mac OS X 10.6.8系统,APUE代码是《UNIX环境高级编程(第二版)》,解压后为apue.2e文件夹)
在之前编译时,遇到过CMSG_LEN未定义的问题,根据http://www.apuebook.com/上的FAQs第10条,将CMSG_LEN的定义从系统include文件中找到了CMSG_LEN,在apue.h加了CMSG_LEN的定义,可以编译通过,但是接下来又遇到问题:
loop.c里的error: ‘fd_set’ undeclared。
fd_set是一个struct,将#include <sys/select.h>加进来可以解决问题。
但是紧接着又有major与minor宏未定义的问题,也可以通过查找macOS的/usr/include下grep查找找到头文件解决问题。
根据文章上面写的方法,就没有定义_XOPEN_SOURCE了。也就不遵循标准了?
查了一下关于_XOPEN_SOURCE
it tells your compiler to include definitions for some extra functions that are defined in the X/Open and POSIX standards.
This will give you some extra functionality that exists on most recent UNIX/BSD/Linux systems, but probably doesn't exist on other systems such as Windows.
The numbers refer to different versions of the standard.
500 - X/Open 5, incorporating POSIX 1995
600 - X/Open 6, incorporating POSIX 2004
700 - X/Open 7, incorporating POSIX 2008
具体的作用还得有时间再摸索摸索。
相关文章推荐
- MacOS X 10.8 下 编译APUE代码清单(apue.2e 第二版源码)
- [整] Mac OS X 10.6 下 android 源码编译
- Mac OS X 10.6下android源码编译
- Mac OS X 10.8.X编译Android4.2.X源码不生成emulator的问题
- Mac OS X Lion 下编译Android 源码
- Android 源码编译 MacOS X环境
- Mac OS X 10.10 编译代码出错 fatal error: '__debug' file not found #include <__debug>
- Android学习——Mac Os X下载和编译android 4.2.2 源码
- mac os/Linux 下命令行C/C++/Java代码编译+运行方法
- Mac OS X 10.10.3下android-5.1.1_r9 源码下载与编译
- Mac OS X 下编译android源码
- MacosX 下GCC编译指定版本的代码
- 在Mac OS X 64bit系统上编译hadoop 2.2源码
- Mac OS X 10.8 中编译APUE(Unix环境高级编程)的源代码过程
- 在Mac OS X 10.10.3下使用源码包编译安装GCC5.1
- Mac OS X下编译Android源码
- Android 入门 - 编译源码(MacOSX)
- MAC OS X 10.10编译android5.0源码 步骤 以及 遇到的问题
- 【原】storm源码之mac os x编译twitter storm源码