能帮看一下这个"multiple definition"的make报错吗?

作者站长头像
站长
· 阅读数 17
/media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: util.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: multiple definition of `tcp_lws_cache'; snort.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: first defined here

/media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: preprocessors/Stream6/libstream6.a(stream_common.o):/home/zhzhy/snort/snort-2.9.81/build/src/preprocessors/Stream6/../../../../src/preprocessors/Stream6/stream_common.h:376: multiple definition of `ip_lws_cache'; snort.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:376: first defined here

所幸这些错误都是multiple definition of...first defined here的形式.足足几十条,随便选了两条.比方说第一条

/media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld:
util.o:
/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373:
multiple definition of `tcp_lws_cache'; 
snort.o:
/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373:
first defined here

链接器ld认为,两个.o文件中包含了重复定义的标识符,但这两个标识符的定义位置都是某个文件的373行,这是同一个定义,这是什么问题?同一个定义不就是一样东西吗?还有第二条.

/media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: preprocessors/Stream6/libstream6.a(stream_common.o):
/home/zhzhy/snort/snort-2.9.81/build/src/preprocessors/Stream6/../../../../src/preprocessors/Stream6/stream_common.h:376:
multiple definition of `ip_lws_cache'; 
snort.o:
/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:376: first defined here

几乎是一回事,只不过是从两个.o文件变成了一个.a文件和.o文件.这种问题是怎么回事呢?恳请赐教.

回复
1个回答
avatar
test
2024-06-27

莫名其妙解决了.简而言之就是1.试试看static,extern.2.每次变动源代码后都要make clean再重新make否则看不到变化.

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容