1

Is there a way in Linux to expose entrypoints from a library (.a) which is linked into a shared library.

Using C/C++ in Windows I can achieve this the following way, but I fail to find a corresponding solution for Linux.

Windows:

Library "component.lib" has entry point like "Object* CreateInstance()", part of "sharedmain.cpp".

When creating the DLL I link with the "component.lib" and set "Module Definition File" pointing to a file with the content.

EXPORTS
    CreateInstance

This effectively results in a DLL with the desired external entrypoint.

Linux:

When building same code for Linux I have not found a way of achieving the same thing.

I've tried the option of building a library from "sharedmain.cpp" into library "libcomponent.a", then linking it into a shared object but this results in a shared object that does not expose the entrypoint from the library.

As a workaround I instead explicitly build and link the "sharedmain.cpp" into every shared object. But this is not optimal since I'd like to hide this implementation an a library which is used by multiple shared objects.

I've played with the GCC visibility attributes (http://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/) but this does not make any difference. I currently use " extern "C" attribute ((visibility ("default"))) " when specifying the entrypoint.

Any ideas? Is it at all possible?

globbolg
  • 21
  • 2

0 Answers0