简体   繁体   中英

Undefined symbols for architecture arm64 xcode 7.3

I have created a static library with simple math function and built a universal binary with it. Build for active architectures only was set to NO while building this.

lipo -info libcheckC.a
Architectures in the fat file: libcheckC.a are: armv7 x86_64 arm64 

I have added this file to another project and verified that Other linker flags have -ObjC, -lcheckC, $(inherited)

The library is also present under "Build Phases --> Link binary with libraries".

I have created the bridging header and added the header file to my project.

I am still getting the error

Undefined symbols for architecture arm64:
"_squareOf", referenced from:
      checkCLib.ViewController.calculate (__ObjC.UIButton) -> () in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using Xcode 7.3

When I try the command manually, I fire following - copied from Xcode with added -v and going deeper from there. I get following details.

@(#)PROGRAM:ld  PROJECT:ld64-264.3.101
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/
/Users/test/Documents/MyIApps/checkCLib/checkCLib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/lib
Framework search paths:
/Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/
/Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/
Undefined symbols for architecture arm64:
  "_squareOf", referenced from:
  checkCLib.ViewController.calculate (__ObjC.UIButton) -> () in ViewController.o
ld: symbol(s) not found for architecture arm64

The library exists at the mentioned path, contains the symbol and supports the architecture as well.

lipo -info /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a
Architectures in the fat file: /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a are: armv7 x86_64 arm64 

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a

/Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a(square.o):
0000000000000000 T _sqaureOf

Did you add the path to the library in Library Search Paths ?

在此处输入图片说明

In my case, I solved the problem by also adding the include statement for the .c (code) file rather than just the .h (header) file. It seems otherwise XCode was not able to find the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM