Xcode上使用静态库的架构x86_64的未定义符号

时间:2015-04-28 17:24:26

标签: xcode

我是IOS开发的初学者。我尝试构建一个包含swift和Objective C语言的应用程序。在应用程序中,我使用了我使用此命令编译的名为libjjeromq.a的库:

ar -rv libjjermoq.a [liste of files.o]
  • 我已将库添加到链接库。我也添加了库搜索路径。

  • 我添加了标志-ObjC

  • 我已将所有文件.m添加到编译文件源

  • 我已配置标题搜索路径

  • 我测试了libjjeromq.a库,它可以在x86_64架构上运行。

但是当我建立时,我得到这样的错误:

Undefined symbols for architecture x86_64:
  "_IOSArray_throwOutOfBoundsWithMsg", referenced from:
      _OrgZeromqZMQ_pollWithOrgZeromqZMQ_PollItemArray_withInt_withLong_ in ZMQ.o
      -[OrgZeromqZMQ_Poller unregisterWithOrgZeromqZMQ_Socket:] in ZMQ.o
      _OrgZeromqZMQ_Poller_removeWithInt_ in ZMQ.o
      -[OrgZeromqZMQ_Poller unregisterWithJavaNioChannelsSelectableChannel:] in ZMQ.o
      -[OrgZeromqZMQ_Poller getItemWithInt:] in ZMQ.o
      -[OrgZeromqZMQ_Poller getSocketWithInt:] in ZMQ.o
      -[OrgZeromqZMQ_Poller pollWithLong:] in ZMQ.o
      ...
  "_IOSClass_class_", referenced from:
      _ZmqStreamEngine_new_decoderWithInt_withLong_withZmqSessionBase_withInt_ in StreamEngine.o
      _ZmqStreamEngine_new_encoderWithInt_withZmqSessionBase_withInt_ in StreamEngine.o
      _ZmqStreamEngine_new_decoderWithInt_withLong_withZmqSessionBase_withInt_ in libjjermoq.a(StreamEngine.o)
      _ZmqStreamEngine_new_encoderWithInt_withZmqSessionBase_withInt_ in libjjermoq.a(StreamEngine.o)
  "_IOSClass_forNameWithNSString_", referenced from:
      -[ZmqOptions setsockoptWithInt:withId:] in Options.o
      -[ZmqOptions setsockoptWithInt:withId:] in libjjermoq.a(Options.o)
  "_IOSClass_fromClass", referenced from:
      ___OrgZeromqZMQ_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_Context_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_Socket_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_Poller_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_PollItem_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_ErrorEnum_class__block_invoke in ZMQ.o
      ___OrgZeromqZMQ_Event_class__block_invoke in ZMQ.o
      ...
  "_IOSClass_fromProtocol", referenced from:
      ___OrgZeromqZLoop_IZLoopHandler_class__block_invoke in ZLoop.o
      ___OrgZeromqZThread_IAttachedRunnable_class__block_invoke in ZThread.o
      ___OrgZeromqZThread_IDetachedRunnable_class__block_invoke in ZThread.o
      ___ZmqAddress_IZAddress_class__block_invoke in Address.o
      ___ZmqIDecoder_class__block_invoke in IDecoder.o
      ___ZmqIEncoder_class__block_invoke in IEncoder.o
      ___ZmqIEngine_class__block_invoke in IEngine.o
      ...
  "_IOSObjectArray_Set", referenced from:
      _OrgZeromqZMQ_pollWithOrgZeromqZMQ_PollItemArray_withInt_withLong_ in ZMQ.o
      _OrgZeromqZMQ_Poller_insertWithOrgZeromqZMQ_PollItem_ in ZMQ.o
      _OrgZeromqZMQ_Poller_removeWithInt_ in ZMQ.o
      -[OrgZeromqZMQ_Poller pollWithLong:] in ZMQ.o
      _OrgZeromqZLoop_rebuild in ZLoop.o
      -[ZmqCtx create_socketWithInt:] in Ctx.o
      -[ZmqCtx destroy_socketWithZmqSocketBase:] in Ctx.o
      ...
  "_IOSObjectArray_SetAndConsume", referenced from:
      _ZmqMtrie_add_helperWithByteArray_withInt_withZmqPipe_ in Mtrie.o
      _ZmqPipe_pipepairWithZmqZObjectArray_withZmqPipeArray_withIntArray_withBooleanArray_ in Pipe.o
      _ZmqProxy_proxyWithZmqSocketBase_withZmqSocketBase_withZmqSocketBase_ in Proxy.o
      -[ZmqTrie addWithByteArray:withInt:] in Trie.o
      _ZmqMtrie_add_helperWithByteArray_withInt_withZmqPipe_ in libjjermoq.a(Mtrie.o)
      _ZmqPipe_pipepairWithZmqZObjectArray_withZmqPipeArray_withIntArray_withBooleanArray_ in libjjermoq.a(Pipe.o)
      _ZmqProxy_proxyWithZmqSocketBase_withZmqSocketBase_withZmqSocketBase_ in libjjermoq.a(Proxy.o)
      ...

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

问题在于有两个不同的文件位于两个不同的曲目中,但它们具有相同的名称!文件是:org / zeromq / zmq.o和zmq / zmq.o。

创建库的过程:ar -rv libjjermoq.a [liste of files.o]随机选择它找到的第一个zmq.o并忽略另一个!结果,在结果库中找不到错过的zmq.o中定义的方法.a。

解决方法是重命名其中一个文件,并避免在所有情况下都有2个或更多具有相同名称的文件,即使它们位于不同的曲目中也是如此!