Does OpenJDK statically link the C++ runtime?
kelly.ohair at oracle.com
Wed Jan 4 22:15:00 UTC 2012
On Jan 3, 2012, at 10:16 PM, John Von Seggern wrote:
> Does OpenJDK continue to take this approach?
Depends on who does the build. The default might be to statically link, pretty sure anyway.
> I'm asking because I would like to use the Java Native Interface to
> call functions in a C++ library (that statically links the C++
> runtime). When I distribute my application, do I need to worry about
> C++ ABI compatibility issues?
When you distribute a C++ application you always need to worry about compatibility issues.
If you statically link in a C++ library, you need to make sure you are not also providing those
interfaces as your own public exported interfaces, if you use the proper version scripts (mapfiles) this
kind of thing can work fine. But it means that you have baked in the implementation of code that
you don't maintain, and any bugs in that code requires you to rebuild your product and re-ship.
There is a maintenance cost to static linking.
So in general, doing static linking is a bad idea and should not be done lightly, if ever.
On Solaris, in OpenJDK makefiles, there is no static linking, or shouldn't be any.
On Windows, we do static linking of some DLLs, but not the primary one MSVCR100.DLL,
except in rare cases, which I try to burn from my memory every time I see them,
and we have lots of debates on that issue. With Windows you have to ship the
MSVC*.DLLs with your product, so there are space considerations, big DLLs here.
On Linux, we shouldn't use static linking, but we had to a long time ago, and we just haven't undone
it completely. Obviously the distros don't want static linking, but when Oracle builds a Linux
distribution, the binaries need to run on a variety of Linux systems, so we need to be careful, and
we don't want to build a separate Oracle JDK for every Linux distro.
It is quite possible that we don't need to static link anything anymore, but that would need to be verified.
When the initial JDK4 work was done on Linux, static links of the C++ runtime was the only way
for us to create binaries that had any chance of running on a variety of distributions of Linux.
Of course, then there is the other sharing issue, the one where you copy the source into your
repository and build your own private version of a library that also ships with the underlying system.
That's another story.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the build-dev