Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

ios - Error: "File was built for archive which is not the architecture being linked (armv7s)"

I have built my own Static C++ Library, which is built with the settings:

  • Architectures: armv7, armv7s
  • Build Active Architectures Only: No
  • Support Platforms: iOS
  • Valid Architectures: armv7, armv7s

The library project builds well and I got the .a file (I have cleaned the build folder and built the project again to be sure my settings were effective).

I have added the library (.a file) to my iOS project, but the project won't build even though I have set the exact same settings on the iOS project:

  • Architectures: armv7s, armv7
  • Build Active Architectures Only: Yes
  • Support Platforms: iOS
  • Valid Architectures: armv7, armv7s

I keep getting this error:

ld: warning: ignoring file /Users/hidden/Library/Developer/Xcode/DerivedData/HelloWorldCppLib-fomvvtklwijvqicyhahxleiscein/Build/Products/Debug-iphoneos/libHelloWorldCppLib.a, file was built for archive which is not the architecture being linked (armv7s): /Users/hidden/Library/Developer/Xcode/DerivedData/HelloWorldCppLib-fomvvtklwijvqicyhahxleiscein/Build/Products/Debug-iphoneos/libHelloWorldCppLib.a

What am I missing? It tells me the .a file was not built for armv7s, but that is exactly the settings I built the library with.

question from:https://stackoverflow.com/questions/14828693/error-file-was-built-for-archive-which-is-not-the-architecture-being-linked-a

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into a similar problem myself. @graver's solution is definitely valid.

The issue was that the library was being built for armv7 instead of armv7s. You can verify this yourself by using lipo <path/to/lib.a> -info.

Setting the Build Active Architectures Only option to No fixes the issue.

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...