0

Can I use .a file in a project that needs to be compiled both to .a and .so?

I need to write a C++ lib, and compile it such that it could be used in another project which is compiled both to .a file (for iOS) and .so file (for Android). I wonder if I compile my C++ lib to an .a lib it could be used later for both Android and iOS.

Further clarification: I am not searching for how to convert static libraries to shared libraries. I am looking for one compiled library that rules them all, hence could be used as is both for iOS and Android projects, for all relevant Architectures.

  • 1
    i usually add the sources to both projects. So android (ndk) and ios can each build that lib for the architectures that are needed. But im curious if someone has a better solution... – Simon Meyer May 31 '15 at 14:12
  • 1
    If you have `foo.a` you can extract the source files from it, and then build `foo.so`. Does that answer your question? – Beta May 31 '15 at 14:13
  • @Beta, I have the source C++ code, but I want to compile it in such way that one can not extract the source file, but can use the lib I provide, both for iOS and Android. So I think it doesn't answer my need. Thanks! – Itamar Mar May 31 '15 at 14:31
  • I misspoke; you can extract the *object* files, not the source files. Does that answer your need? – Beta May 31 '15 at 15:11
  • @Beta , you mean that you can extract the `.o` files from it, right? (not the source files). Can you explain the process you do? For example, how you build the `.so` from the `.o` files. Thanks. – Itamar Mar May 31 '15 at 15:47
  • possible duplicate of [Convert a Static Library to a Shared Library?](http://stackoverflow.com/questions/655163/convert-a-static-library-to-a-shared-library) –  May 31 '15 at 22:37

0 Answers0