Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 强制忽略重复符号?_C++_C_Macos_Ld - Fatal编程技术网

C++ 强制忽略重复符号?

C++ 强制忽略重复符号?,c++,c,macos,ld,C++,C,Macos,Ld,我正在从使用静态库的项目中构建一些遗留代码。现在,我遇到了很多这样的错误: ld: warning: option -m is obsolete and being ignored ld: duplicate symbol <function name> ld:警告:选项-m已过时,正在被忽略 重复符号 有没有办法强制完成构建。从我所看到的“复制”函数是相同的,只是构建过程失控了。这个项目真的很大(而且遗留了大量的C和C++代码),我真的很想避免花几个小时来研究构建过程。有“快速

我正在从使用静态库的项目中构建一些遗留代码。现在,我遇到了很多这样的错误:

ld: warning: option -m is obsolete and being ignored
ld: duplicate symbol <function name>
ld:警告:选项-m已过时,正在被忽略
重复符号

有没有办法强制完成构建。从我所看到的“复制”函数是相同的,只是构建过程失控了。这个项目真的很大(而且遗留了大量的C和C++代码),我真的很想避免花几个小时来研究构建过程。有“快速修复”吗?我真的只需要运行这个程序一次,这样我就可以忍受(一些)稳定性问题。

在我的系统上搜索
man ld
(用于“复制”),发现:


试试看。也许它能解决您的问题。

从GNU
ld
手册页:

       --allow-multiple-definition
       -z muldefs
           Normally when a symbol is defined multiple times, the linker will
           report a fatal error. These options allow multiple definitions and
           the first definition will be used.

那是去哪个站台的?这个选项在MacOSX上不可用。但是,我在Ubuntu机器上尝试了它,但没有成功。从手册页上看,它听起来更像是与调试符号有关。这是我的Debian机器(ld v 2.21.0.20110327)上的
man ld
的输出。我没有测试它。很抱歉,它不适用于您。我认为这是“安全”的,当且仅当重复的符号定义相同时?如果有一个更为谨慎的“允许相同的定义”,如果存在多个不同的定义,这将是致命的
       --allow-multiple-definition
       -z muldefs
           Normally when a symbol is defined multiple times, the linker will
           report a fatal error. These options allow multiple definitions and
           the first definition will be used.