0

I'm trying to create a Python module for Cpython. The C is compiled with some libraries as a -shared .so file. However, I want to include the dependencies inside the .so file to make it more portable. Compiling it into a static .a file doesn't work because it cannot be dynamically loaded, and I can't specify both -static and -shared when compiling the same file. So how do I go about creating a shared object with libraries statically included using gcc? There has to be a way other than downloading the dependency headers into the directory.

Thanks.

id01
  • 1,491
  • 1
  • 14
  • 21
  • Possible duplicate of [Convert a Static Library to a Shared Library?](https://stackoverflow.com/questions/655163/convert-a-static-library-to-a-shared-library) –  Sep 12 '17 at 20:58
  • 2
    The python extension module must be a shared .so, but it can include code from statically linked libraries (.a). Fortunately, those are different files, so they can be static when you compile them. If they are built as .so files, then you will need to have them available. Python finds the extension, which you import, on the PYTHONPATH. Then the operating system finds the other so dependencies according to however your OS loads dependent .so files (e.g. LD_LIBRARY_PATH) – Kenny Ostrom Sep 12 '17 at 21:41
  • This works, but seems to require you to download the source code of all the libraries you have and compile them to .a files, or find the .a files in your current install. Is there a better way? – id01 Nov 02 '17 at 03:18

0 Answers0