Skip to content

Instantly share code, notes, and snippets.

@aont
Created July 17, 2025 00:54
Show Gist options
  • Select an option

  • Save aont/b9e3541012ce9c6f17d7f6ac1c35572b to your computer and use it in GitHub Desktop.

Select an option

Save aont/b9e3541012ce9c6f17d7f6ac1c35572b to your computer and use it in GitHub Desktop.

Converting .a to .so

Use the .o files inside the .a archive to create a .so

  1. Extract the .a archive:

    ar x libsomething.a

    → This will extract the object (.o) files contained within.

  2. Create the .so shared library (compatible up to C++11):

    g++ -shared -fPIC *.o -o libsomething.so

    Notes:

    • The -fPIC flag generates position-independent code, which is required for shared libraries. If the original .a was not compiled with -fPIC, this method may fail.
    • If there are any dependencies, link them explicitly using -l flags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment