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





