Wednesday, September 25, 2013

Mac Xcode4 how to put a static library. A added to the project, and call the static library function

Party gave a mac os x on the static library and header files files XX.a XX.h, such as the library has a function called Add ()
I put this on in Xcode added into the library,
First # include "XX.h" file in the main function is to direct the calling code
# Include "XX.h"
int main ()
{
Add ();
}
There are two error compiling a warning:
ld: warning ": ignoring file .. / XX.a, file was built for archive which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:

ld: symbol (s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use-v to see invocation)
How to call the library function Add () do? Call the library function format is kind of how?
Reply:
Judge from the warning, you use the library and do not match your current project. Therefore. A file is ignored.
Since the. A is omitted, then tune. A compilation functions in place is definitely wrong.
I do not know that you are not doing iOS, if the library is compiled simulator, using a project for the real machine translation. Or both, in turn, will produce this link error problem.
Reply:
I have encountered this problem. . A library is divided into two types, one based on X86, and can only run on the simulator. One is based on ARM, which is only running on a real machine
Reply:
landlord fcjsj061 reply quote:
third gave a mac os x on a static library and header files files XX.a XX.h, such as libraries There is a function called Add ()
I put this on in Xcode added into the library,
First # include "XX.h" file in the main function is to direct the calling code
# Include "XX.h"
int main ()
{
Add ();
}
There are two error compiling a warning:
ld: warning "......

Not the iphone on IOS. Then how do I do now?
Reply:
quote 1 floor tlb203 reply:
judge from the warning, you use the library and do not match your current project. Therefore. A file is ignored.
Since the. A is omitted, then tune. A compilation functions in place is definitely wrong.
I do not know that you are not doing iOS, if the library is compiled simulator, using a project for the real machine translation. Or both, in turn, will produce this link error problem.

I am not a developer IOS application, how do you solve?
Reply:
I used lipo-info XX.a view, display the results are:
lipo: archive with no architecture specification: XX.a (cann't determine architecture for it)
Reply:
With lipo-info XX.a view your library belongs to which architecture to use, it is best to get a hybrid library supports both X86 and arm7.
Reply:
Is armv7
Reply:
Results posted: It is because of third-party libraries to have problems again gave a library with lipo-info specifies the architecture can be seen

No comments:

Post a Comment