Mac下编译"Unix环境高级编程"的apue.h的错误解决
2016-06-26 00:27
585 查看
1. 首先在这里下载代码文件.
2. 根据解压之后README里面所述To build the source, edit the Make.defines.* file for your system and set WKDIR to the pathname of the tree containing the source code.修改Make.defines.macos文件内容,把第六行WKDIR后面的内容改为你的apue.h的解压路径.
3. 这时候先别急着make, 因为你make了会遇到一个"_CMSG_LEN"错误, 如下图:
继续看README里面If you are running on a system other than FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles to include the settings for your system. Also, you'll probably need to modify the source code to get it to build on a different operating
system.
也就是说我们需要自己改改代码, 打开apue的include文件夹编辑其中的apue.h我们可以看到_CMSG_LEN_其实是有定义的,只不过在条件编译的时候每判断出Mac OS X而已, 依葫芦画瓢, 在第八行之后加入一下代码:
#elif defined(MACOS)
#define CMSG_LEN(x) _CMSG_DATA_ALIGN(sizeof(struct cmsghdr)+(x))
Ok自此可以正常编译了. 如果之前你不慎先make了, 那么你需要先make clean之后在make.
2. 根据解压之后README里面所述To build the source, edit the Make.defines.* file for your system and set WKDIR to the pathname of the tree containing the source code.修改Make.defines.macos文件内容,把第六行WKDIR后面的内容改为你的apue.h的解压路径.
3. 这时候先别急着make, 因为你make了会遇到一个"_CMSG_LEN"错误, 如下图:
继续看README里面If you are running on a system other than FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles to include the settings for your system. Also, you'll probably need to modify the source code to get it to build on a different operating
system.
也就是说我们需要自己改改代码, 打开apue的include文件夹编辑其中的apue.h我们可以看到_CMSG_LEN_其实是有定义的,只不过在条件编译的时候每判断出Mac OS X而已, 依葫芦画瓢, 在第八行之后加入一下代码:
#elif defined(MACOS)
#define CMSG_LEN(x) _CMSG_DATA_ALIGN(sizeof(struct cmsghdr)+(x))
Ok自此可以正常编译了. 如果之前你不慎先make了, 那么你需要先make clean之后在make.
相关文章推荐
- Databus系统构想 Client端(一)
- UISearchBar
- Request对象的主要方法
- 从SystemUI电池图标的显示探讨Android电池管理
- iOS 时间/ 日期选择器 UIDatePicker
- UUID
- UIViewController的使用说明及其生命周期
- 记录一些遇到的坑
- soapui笔记7:断言2
- soapui笔记6:断言1
- Android UI根据屏幕分辨率决定加载布局
- map如何按value来排序------用带pair的vector吧
- Android 仿iOS的UISegmentControl标题栏以及内容切换
- UE4打包的exe运行未响应解决方法
- soapui笔记5:项目导入
- REQUEST_URL PHP_SELF SCRIPT_NAME区别
- MUI使用pullRefresh后,scrollToBottom无法使用的解决方案
- RML-怎样的语句会被归纳为同一类型(Unique Batches)
- soapui笔记3:创建一个新的项目
- leetcode 357. Count Numbers with Unique Digits 解题报告