Hi Pavel,
That may depend on which architecture you are talking about.
On Linux it is definitely possible to link a static library (.a) into the shared support library (.so).
Here is an example. My Makefile contains this line:
LIB_LIBS += PvAPI
This is libPvAPI.a, which is a static vendor library:
-r--r--r-- 1 epics epics 2053154 Aug 6 09:34 libPvAPI.a
When I link my shared support library this is what I get:
-r-xr-xr-x 1 epics epics 1250968 Sep 22 11:08 libprosilica.so
Note that it is about 1.25 MB.
I then comment out the LIB_LIBS line in my Makefile and build again. This is what I get:
-r-xr-xr-x 1 epics epics 115746 Sep 22 11:09 libprosilica.so
So now it is only 0.12 MB because libPvAPI.a is not linked into the shareable library.
Interestingly you will note that Linux does not give an error when the LIB_LIBS line is commented out. Linux is happy to build a shareable library with unresolved references.
In this case libPvAPI.a would need to be linked into the final application, but it does not need to be linked into the shareable library.
This is NOT true on Windows, either Visual Studio or Cygwin. In that case when building the shareable library (.dll) all references must be resolved, so the LIB_LIBS link
is required.
I believe that Windows will also allow linking a static library into a DLL, but I could not quickly find an example to prove it.
Mark
From: [email protected] [mailto:[email protected]]
On Behalf Of Pavel Maslov
Sent: Monday, September 22, 2014 10:34 AM
To: EPICS Tech Talk
Subject: build shared library using static library
Is it possible to build a shared library (EPICS support module) using one or more static libraries?
I know that it works out when building an IOC. But what about support libs?
Regards,
Pavel Maslov, MS