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

/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文件.
这种问题是怎么回事呢?恳请赐教.

阅读 2.5k
1 个回答

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

推荐问题
宣传栏