zoukankan      html  css  js  c++  java
  • apue 在 mac 环境编译错误

    参考资料: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.

  • 相关阅读:
    简单多线程创建
    ajax 实现局部页面更新
    基础分页查询解题思路
    cookie实现登录时间记录
    servlet过滤器
    jstl标签 URL智能寻找路径
    taglib遍历foreach循环list集合
    python之内置高阶函数
    python之lambda的使用
    python中的函数
  • 原文地址:https://www.cnblogs.com/DillGao/p/10400024.html
Copyright © 2011-2022 走看看