Swift命令行链接失败,出现“重复符号”错误

时间:2018-06-07 09:04:02

标签: swift macos swift4 swift4.1 perfect

我在Package.swift中引用了一些C项目。最近我添加了一个在其自己的Package.swift文件中引用其他C项目的项目,虽然这些C项目与我引用的项目不同,但它们包含同名目标文件。使用swift buildswift run在命令行上构建会在链接期间出现“重复符号”错误。

e.g。

duplicate symbol _http_message_needs_eof in:
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/CHTTPParser.build/http_parser.c.o
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/PerfectCHTTPParser.build/http_parser.c.o
duplicate symbol _http_should_keep_alive in:
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/CHTTPParser.build/http_parser.c.o
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/PerfectCHTTPParser.build/http_parser.c.o
duplicate symbol _http_parser_execute in:
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/CHTTPParser.build/http_parser.c.o
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/PerfectCHTTPParser.build/http_parser.c.o
duplicate symbol _http_parser_pause in:
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/CHTTPParser.build/http_parser.c.o
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/PerfectCHTTPParser.build/http_parser.c.o
duplicate symbol _http_errno_name in:
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/CHTTPParser.build/http_parser.c.o
    /Users/tyress/private/.build/x86_64-apple-macosx10.10/debug/PerfectCHTTPParser.build/http_parser.c.o

构建最终以<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)失败(即使使用-v构建此消息也会显示)

在Xcode 9.3上构建它不会产生这样的错误,并且在调试时正常运行。

我能做些什么来防止这个版本因重复而失败?我需要能够通过命令行构建它。

0 个答案:

没有答案