我在我的项目中使用了paho MQTT库。
当我在模拟器上构建项目时,我遇到了以下错误。
duplicate symbol _client_version_eye in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTClient.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolClient.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Socket.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPersistence.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Thread.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolOut.o
ld: 25 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
答案 0 :(得分:1)
试试吧......
将一个文件的内容复制并粘贴到另一个文件时,可能会发生错误,该文件的接口名称为两个具有相同接口名称的类。
在您的代码中,您有两个具有相同接口名称的不同文件。
问题很可能是由于包含标题时的拼写错误。
检查是否包含头文件(.h)而不是实现文件(.m)。
同时清理项目和构建文件夹有时它也会解决此错误
同时删除派生数据。
答案 1 :(得分:1)
MQTTClient.c和MQTTAsync.c不应包含在同一项目中。它们用于构建不同的库。确定是否需要阻止或异步行为并使用该文件。