Apple Mach-O Linker Errors (20) - Undefined symbols for architecture armv7

爷,独闯天下 提交于 2019-11-30 11:01:13

问题


I received these errors after I added " -all_load " in the "Other Linker Flags" build setting once I added "libPusher-combined.a" and its header files. I followed the instructions exactly up to the part of typing in "-all_load" (under "Using a pre-compiled static library" in the "Adding to your iOS Project", but I ended up getting 20 Mach-O Linker errors. :/ Could anyone please help me with this?

Here are the errors:

Undefined symbols for architecture armv7:
 "_utf8_nextCharSafeBody", referenced from:
  -[SRWebSocket _pumpScanner] in libPusher-combined.a(SRWebSocket.o)
 "_SCError", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
 "_utf8_countTrailBytes", referenced from:
  -[SRWebSocket _pumpScanner] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilitySetDispatchQueue", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
  -[Reachability stopNotifier] in libPusher-combined.a(Reachability.o)
 "_kCFHTTPVersion1_1", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
"_CFHTTPMessageIsHeaderComplete", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCreateRequest", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilityCreateWithAddress", referenced from:
  +[Reachability reachabilityWithAddress:] in libPusher-combined.a(Reachability.o)
 "_SCErrorString", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
 "_SCNetworkReachabilityCreateWithName", referenced from:
  +[Reachability reachabilityWithHostname:] in libPusher-combined.a(Reachability.o)
 "_CFHTTPMessageCopyAllHeaderFields", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageGetResponseStatusCode", referenced from:
  -[SRWebSocket _HTTPHeadersDidFinish] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageSetHeaderFieldValue", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
  ___25-[SRWebSocket didConnect]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCreateEmpty", referenced from:
  -[SRWebSocket _readHTTPHeader] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCopySerializedMessage", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilitySetCallback", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
  -[Reachability stopNotifier] in libPusher-combined.a(Reachability.o)
 "_SCNetworkReachabilityGetFlags", referenced from:
  -[Reachability isReachable] in libPusher-combined.a(Reachability.o)
  -[Reachability isReachableViaWWAN] in libPusher-combined.a(Reachability.o)
  -[Reachability isReachableViaWiFi] in libPusher-combined.a(Reachability.o)
  -[Reachability connectionRequired] in libPusher-combined.a(Reachability.o)
  -[Reachability isConnectionOnDemand] in libPusher-combined.a(Reachability.o)
  -[Reachability isInterventionRequired] in libPusher-combined.a(Reachability.o)
  -[Reachability reachabilityFlags] in libPusher-combined.a(Reachability.o)
  ...
 "_CFHTTPMessageCopyHeaderFieldValue", referenced from:
  -[SRWebSocket _checkHandshake:] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageAppendBytes", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If you need more information, just ask. I hope that I'm not giving too much trouble. Thanks in advance.


回答1:


Can you check out in your target->Build Phase. whether these files exist there or not ? and if you are running for simulator then first you need to make a build for simulator of that library whatever i guess you are using SRWebSocket library. Just open that project and just make a build for simulator and copy the files from build folder and then add to your project and do the same for the device if you are running your app on device.




回答2:


Check to make sure you included the following frameworks (via https://github.com/square/SocketRocket) :

Framework Dependencies

Your .app must be linked against the following frameworks/dylibs

libicucore.dylib CFNetwork.framework Security.framework Foundation.framework




回答3:


Make sure that you also have -licucore in "Other Linker Flags", in the build settings tab, as in the attached screenshot:




回答4:


I copied the complete SocketRocket folder into my application for using web sockets in my application and linked libicucore.dylib, CFNetwork.framework, Security.framework, Foundation.framework binaries with my project. This removed all my errors and warnings.




回答5:


For the latest sdk, you should add:

libicucore.tbd 

since libicucore.dylib is not present anymore.

hope .tbd extension is not for "to be delete"?




回答6:


In my case when I added SystemConfiguration.framework to the project and problem went... :-)



来源:https://stackoverflow.com/questions/9931510/apple-mach-o-linker-errors-20-undefined-symbols-for-architecture-armv7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!