Does OpenJDK statically link the C++ runtime?

Volker Simonis volker.simonis at
Wed Jan 4 10:09:30 UTC 2012

Regarding your first question: yes, at least the HotSpot (i.e. still statically links libstdc++.

You can verify this by looking at make/linux/makefiles/vm.make:

ifeq ($(SHARK_BUILD), true)
  STATIC_CXX = false
  ifeq ($(ZERO_LIBARCH), ppc64)
    STATIC_CXX = false
    STATIC_CXX = true


  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
  # get around library dependency and compatibility issues. Must use gcc not
  # g++ to link.
  ifeq ($(STATIC_CXX), true)
    LFLAGS_VM              += $(STATIC_LIBGCC)
    LIBS_VM                += $(STATIC_STDCXX)
    LIBS_VM                += -lstdc++

So for any build except SHARK build and ZERO builds on ppc64,
libstdc++ is statically linked.

STATIC_STDCXX is defined in make/linux/makefiles/gcc.make as:

# statically link, work with gcc but ignored by g++
STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic


On Wed, Jan 4, 2012 at 7:16 AM, John Von Seggern <vonseg at> wrote:
> Way back in a bug report for Java 1.4, I found this note:
> "We statically link the C++ runtime in JDK and enabled linker script
> to hide symbols from libstdc++ and other internal symbols."
> --
> Does OpenJDK continue to take this approach?
> 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?
> In case it's useful to anyone, I also asked this question on StackOverflow:
> (I figured I'd also try asking here, too.  I apologize if this is the
> wrong place.)
> Thanks,
> -John

More information about the build-dev mailing list