title: Error: ld: warning: ignoring file libfile01.a, file was built for archive which is not the architecture being linked (armv7): libfile01.a
body: <p>I'm trying to compile a project developed in C language for iOS devices. It uses custom library file, libcurl, libcrypto, libssl and libpthread. I have successfully compiled it for Mac OS X, but having issues compiling it for iOS. Also, any help I try to find online is more of Xcode GUI help, and I need command line help for it. Need to compile it through commands instead of Xcode GUI.</p>
  
  <p>First it needs to compile couple of C files, then make a static library file out of these compiled files, which further used when compiling a native binary.</p>
  
  <hr>
  
  <p>This is how I generated iOS arm ouptut files from c files inside file01:</p>
  
  <p>Store the iphoneos sdk path in environemnt variable:</p>
  
  <pre><code>CC="$(xcrun --sdk iphoneos9.2 --find clang) -isysroot $(xcrun --sdk iphoneos9.2 --show-sdk-path) -arch armv7 -arch armv7s -arch arm64 -arch armv6 -arch arm64"
  </code></pre>
  
  <p>Compile the c files in file01 with command:
  <code>$CC -c -O2 *.c</code></p>
  
  <p>To check which architect these files are compiled for can be checked with this <code>lipo</code> command. Example:</p>
  
  <pre><code>$ lipo -info example_file01.o 
  Architectures in the fat file: example_file01.o are: armv7 armv7s armv6 arm64
  </code></pre>
  
  <p>To make a static library file I can get iOS <code>ar</code> file path using command:</p>
  
  <pre><code>$ xcrun --sdk iphoneos9.2 --find ar /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
  </code></pre>
  
  <p>I could store the path in an environment variable, but it was not working throwing error not recognising <code>ar</code> command arguments <code>rcu</code>. So, used the <code>ar</code> path instead to create the library file with this command:</p>
  
  <pre><code>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar rcu ../output/libfile01.a *.o
  </code></pre>
  
  <p>If checking which architectures this lib file supports it gives this output:</p>
  
  <pre><code>$ lipo -info ../output/libfile01.a 
  fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: archive with no architecture specification: ../output/libfile01.a (can't determine architecture for it)
  </code></pre>
  
  <p>But, it should have given output similar to this one:</p>
  
  <pre><code>$ lipo -info ../ios/lib/libcurl.a 
  Architectures in the fat file: ../ios/lib/libcurl.a are: i386 armv7 armv7s x86_64 arm64
  </code></pre>
  
  <p>This is causing error when trying compiling files in using the generated static lib file with command:</p>
  
  <pre><code>$CC -o ../output/FinalProjectFile -O2 *.c ../output/libfile01.a ../ios/lib/libcurl.a ../ios/lib/libssl.a ../ios/lib/libcrypto.a -lpthread -lm
  
  Error: ​ld: warning: ignoring file ../output/libfile01.a, file was built for archive which is not the architecture being linked (armv7): ../output/libfile01.a​
  </code></pre>
  
  <p>Thanks for help</p>