参考资料:https://unix.stackexchange.com/questions/105483/compiling-code-from-apue

笔者使用 mac 学习 apue, 在编译的时候出现错误,错误如下:

Undefined symbols for architecture x86_64:
"_TELL_CHILD", referenced from:
_main in 14_5-4244a7.o
"_TELL_PARENT", referenced from:
_main in 14_5-4244a7.o
"_TELL_WAIT", referenced from:
_main in 14_5-4244a7.o
"_WAIT_CHILD", referenced from:
_main in 14_5-4244a7.o
"_WAIT_PARENT", referenced from:
_main in 14_5-4244a7.o
"_err_sys", referenced from:
_lock_test in 14_5-4244a7.o
_main in 14_5-4244a7.o
_lockabyte in 14_5-4244a7.o
"_lock_reg", referenced from:
_lockabyte in 14_5-4244a7.o
ld: symbol(s) not found for architecture x86_64

在解决该问题时浪费很多时间,记下解决办法,希望可以帮助到你。

前提:已经正确安装 apue,安装方法自行搜索,路径如下:

DilldeMacBook-Pro:apue.3e dill$ pwd
/Users/dill/Downloads/apue.3e
DilldeMacBook-Pro:apue.3e dill$ cp include/* /usr/local/include/
DilldeMacBook-Pro:apue.3e dill$ cp lib/* /usr/local/lib/

避免上文的编译错误,采用如下命令编译:

gcc -o myls myls.c -I /usr/local/include -L /usr/local/lib/ -lapue

myls.c 为需要编译的 C 文件

-I 为 gcc 指定 include 地址

-L 为 gcc 指定 library 地址

-lapue 指定在 lib 文件夹中  library 文件名("/usr/local/lib/libapue.a")

-LXXX means to look for a file in the library directory with the name: libXXX.a or libXXX.so.

apue 在 mac 环境编译错误的更多相关文章

  1. lamp环境编译错误

    GD 编译出错解决方法 编译最新的2.0.35版本,用默认的 ./configure编译 当make的时候,出现以下错误 configure.ac:64: error: possibly undefi ...

  2. mac gcc 编译错误 基础问题

    mac gcc  Undefined symbols for architecture x86_64 "std::__1: // Undefined symbols for architec ...

  3. 编译错误“The run destination My Mac 64-bit is not valid for Running the scheme '***',解决办法

    1. iOS APP Project or  Mac APP Project编译错误提示:
“The run destination My Mac 64-bit is not valid for Ru ...

  4. 编译错误“The run destination My Mac is not valid for Running the scheme '***',解决办法

    [转载]   http://blog.csdn.net/duanyipeng/article/details/8007684   编译错误"The run destination My Ma ...

  5. Android编译环境——ubuntu12.04上android2.3.4编译错误以及解决

    Android编译环境——ubuntu12.04上android2.3.4编译错误以及解决 分类: android应用开发2013-08-21 09:20 4222人阅读 评论(3) 收藏 举报 li ...

  6. mac 环境下Android 反编译源码

    mac环境下Android 反编译 一.需要的工具 apktool:反编译APK文件,得到classes.dex文件,同时也能获取到资源文件以及布局文件. dex2jar:将反编译后的classes. ...

  7. Xamarin Studio在Mac环境下的配置和Xamarin.iOS常用控件的示例

    看过好多帖子都是Win环境装XS,Mac只是个模拟器,讲解在Mac环境下如何配置Xamarin Studio很少,也是一点点找资料,东拼西凑才把Xamarin Studio装在Mac上跑起来,如下: ...

  8. (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境

    . . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...

  9. 尝试在Mac上编译DNX

    自从XRE改名为DNX至今,从来没有在Mac OS X上成功编译过DNX.一直很纳闷,难道DNX的开发人员不用Mac?今天突然明白了,DNX的开发人员真的不用Mac.而且DNX用的2个持续集成服务Ap ...

随机推荐

  1. 交叉工具链和makefile

    交叉工具链: arm-linux-gcc:交叉编译器 arm-linux-ld:交叉连接器 arm-linux-readelf:交叉ELF文件工具 arm-linux-objdump:交叉反汇编器 a ...

  2. 三、Vue CLI-单页面

    一.单页面 代码如下: <template> <div class="header">{{title}}</div> </template ...

  3. SpringCloud系列(一):Eureka 注册中心

    在演示spring cloud之前得要知道我们为什么需要微服务框架. 先讲讲我的经历,以前我们做项目时所有功能都写在一起,只是做了分层(模型,数据,业务),所有业务逻辑都写在业务层,刚开始还好,等时间 ...

  4. 费用流 Dijkstra 原始对偶方法(primal-dual method)

    简单叙述用Dijkstra求费用流 Dijkstra不能求有负权边的最短路. 类似于Johnson算法,我们也可以设计一个势函数,以满足在与原图等价的新图中的边权非负. 但是这个算法并不能处理有负圈的 ...

  5. Noip2018退役记。

    下面是边考试边写的严肃版退役记\(:D\) Day0 其实我本来想取个这个名字:\(NOIP2018\)提高组复赛试题解析 但是这个博客自己求生欲望太强自己改名了. 先占个坑. noip考前毒奶 \( ...

  6. 【HDU4276】The Ghost Blows Light

    题目大意:给定一棵有根树,1 号节点为根节点,点有点权,边有边权,初始给定一个价值,每经过一条边都会减少该价值,每经过一个点都会增加相应的答案贡献值,求如何在给定价值的情况下最大化答案贡献,并要求最后 ...

  7. java打分系统

    package com.ioTest; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Fil ...

  8. Python 函数Ⅲ

    默认参数 调用函数时,默认参数的值如果没有传入,则被认为是默认值.下例会打印默认的age,如果age没有被传入: 以上实例输出结果: 不定长参数 你可能需要一个函数能处理比当初声明时更多的参数.这些参 ...

  9. python 使用嵌套函数报local variable xxx referenced before assignment或者 local variable XXX defined in enclosing scope

    情况一: a 直接引用外部的,正常运行 def toplevel(): a = 5 def nested(): print(a + 2) # theres no local variable a so ...

  10. springmvc/springboot开发restful API

    非rest的url写法: 查询 GET /user/query?name=tom 详情 GET /user/getinfo? 创建 POST /user/create?name=tom 修改 POST ...