make arm architecture c library in mac
Posted
by
gamegamelife
on Stack Overflow
See other posts from Stack Overflow
or by gamegamelife
Published on 2011-01-04T11:31:46Z
Indexed on
2011/01/04
17:53 UTC
Read the original article
Hit count: 189
I'm trying to make my own c library in Mac and include it to my iphone program. The c code is simple , like this:
math.h:
int myPow2(int);
math.c:
#include "math.h"
int myPow2(int num) {
return num*num;
}
I search how to make the c library file ( .a or .lib ..etc) seems need to use gcc compiler (Is there other methods?) so I use this command:
gcc -c math.c -o math.o
ar rcs libmath.a math.o
And include it in iPhone Project. Now it has the problem when build xcode iphone project.
"file was built for unsupported file format which is not the architecture being linked"
I found some pages discuss about the problem, but no detail how to make the i386/arm architecture library. And I finally use this command to do it:
gcc -arch i386 -c math.c -o math.o
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 -c math.c -o math.o
I dont know if this method is correct? Or there has another method to do it?
© Stack Overflow or respective owner