Hi Mark,
On 2012-09-26 Mark Rivers wrote:
I would like to build an EPICS shareable library on Linux that is
self-contained, i.e. it does not depend on any other shareable library.
For example, with IDL I would like libezcaIDL.so to not depend on
libca.so, libCom.so, libezca.so, and libEzcaScan.so.
...
But I am looking for a cleaner solution. When EPICS is built with
SHARED_LIBRARIES=YES it actually builds both .a and .so files for every
library. I would like a way to specify that ezcaIDL should be built as a
.so file, but it should be linked with .a files for everything it depends
on.
Is there a way to do this?
You can change the command that we use to link a shared library by modifying
the variable LINK.shrlib in your Makefile. The value for this variable is set
in one or more of the Base/configure/os/CONFIG.* files according to your
platform. For GNU-based platforms we actually use g++ to do the linking
because it has to do more than the ld program normally does when linking C++
code.
Your replacement linker command should use the the -Wl,-Bstatic command-line
option (or any of its synonyms which I won't list here) immediately before any
-l options naming libraries that you want to statically link against, then -
Wl,-Bdynamic (or its synonyms) before the -l options naming shared libraries.
You'll probably want to run this manually to get the right combination.
The EPICS build system doesn't have a way to do this automatically, and I
think it would be rather complicated to try to make it do so. Note that the
resulting Makefile rule probably won't be portable; the above options apply to
the GNU linker, you may have to adjust them for other platforms you want to
use.
HTH,
- Andrew