Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile c++ files for all iOS architectures

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 -------------------------//

enter image description here

//----------------- Error 2 -------------------------//

enter image description here

//----------------- Error 3 -------------------------//

enter image description here

Thanks!

like image 909
Grace Avatar asked Aug 21 '15 08:08

Grace


1 Answers

Have you considered the -arch compiler flag ?

g++ -c file1.cpp file2.cpp -std=c++11 -arch x86_64 -arch i386 -arch armv7 #...
like image 64
Ad N Avatar answered Oct 24 '22 02:10

Ad N