Reputation: 1265
I have some cpp files that I would like to compile it in order to run on simulator and iPhone. What I am trying to do is:
g++ -c file1.cpp file2.cpp -std=c++11
ar rcs libabc.a *.o
And this compiles fine but only for x86_64 architecture..Obviously...
Is there any easy way I can edit these 2 line of command in order to have a library compiled for all architectures (x86_64 i386 armv7 armv7s arm64)? Or should I build some huge scripts to have that library? If so? Is there any ready scripts for that?
I have also tried to run it using -arch:
g++ -c file1.cpp file2.cpp -std=c++11 -arch armv7 -arch x86_64
but these are some errors I'm getting
//----------------- Error 1 -------------------------//
//----------------- Error 2 -------------------------//
//----------------- Error 3 -------------------------//
Thanks!
Upvotes: 7
Views: 1819
Reputation: 2881
Better build for each arch individually and then glue thrm together. It helps in figuring out different or wrongly included platform specific headers and else.
But from my experience, all this isn't worth it if you can avoid building via console. Create an Xcode project and use a fake framework, if it suits you. Or build the static libraries individually and later glue them together yourself.
Upvotes: 0
Reputation: 8376
Have you considered the -arch
compiler flag ?
g++ -c file1.cpp file2.cpp -std=c++11 -arch x86_64 -arch i386 -arch armv7 #...
Upvotes: 4