You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编译apue.h源码时执行make命令报错的问题求助

解决apue.3e编译时的ld链接错误

问题描述

编译apue.3e源码执行make命令时,出现以下链接错误:

gcc -shared -Wl,-dylib -o libapue_db.so.1 -L../lib -lapue -lc db.o
/usr/bin/ld: Error: unable to disambiguate: -dylib (did you mean --dylib ?)
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:32: libapue_db.so.1] Error 1
make[1]: Leaving directory '/home/creative-mode/Downloads/src.3e/apue.3e/db'
make: *** [Makefile:6: all] Error 1

使用的环境版本:

GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

解决方案

  1. 进入apue.3e源码的db目录:
    cd /home/creative-mode/Downloads/src.3e/apue.3e/db
    
  2. 编辑该目录下的Makefile,定位到第32行左右生成libapue_db.so.1的编译命令
  3. 将命令中的-Wl,-dylib参数删除(原命令已包含-shared,无需额外替换),修改后的命令为:
    gcc -shared -o libapue_db.so.1 -L../lib -lapue -lc db.o
    
  4. 保存Makefile,回到apue.3e根目录重新执行make

原因说明

-dylib是Darwin(macOS)平台生成动态库的专属链接参数,Linux平台的ld链接器不支持该参数,Linux下生成动态库使用-shared参数。原Makefile混用了跨平台选项,导致Linux环境编译报错。

内容的提问来源于stack exchange,提问作者ENG21CS0261 Naindeep Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 01:20:07