Ubuntu22 boa(boa-0.94.13.tar.gz) make 编译报错

文章描述了一个在编译Boa源代码时遇到的链接器错误,原因在于config.c试图使用log.c中未声明为extern的变量。解决方法是通过在log.c文件中添加extern关键字来声明这些变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/usr/bin/ld: log.o:/home/slocker/boa-0.94.13/src/log.c:29: multiple definition of `error_log_name'; config.o:/home/slocker/boa-0.94.13/src/config.c:61: first defined here
/usr/bin/ld: log.o:/home/slocker/boa-0.94.13/src/log.c:30: multiple definition of `access_log_name'; config.o:/home/slocker/boa-0.94.13/src/config.c:62: first defined here
/usr/bin/ld: log.o:/home/slocker/boa-0.94.13/src/log.c:31: multiple definition of `cgi_log_name'; config.o:/home/slocker/boa-0.94.13/src/config.c:63: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:43: boa] Error 1

原因:变量的多重定义 

        config.c 中 使用了 log.c 中声明的变量 但 log.c 中未将这些变量 声明为 extern 类型

        

//From config.c

/* These came from log.c */
char *error_log_name;
char *access_log_name;
char *cgi_log_name;

解决方法:extern 关键字的声明,实现外部变量的引用

修改 log.c 31-33 行

//修改后
extern char *error_log_name;
extern char *access_log_name;
extern char *cgi_log_name;

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值