1

The Eclipse project offers installers for Linux. Do these installers (or the installed executables) contain any compiled C++ code? If so, how does Eclipse avoid C++ ABI compatibility issues?

I figured that the native libraries for Eclipse (like SWT) must all be written in C. (Let's ignore Windows for now.) While looking over the source for SWT, I noticed that the XPCOM-related code is written in C++.

So what's the trick? If I install Eclipse from an installer, will I get this stuff? If so, will it work regardless of which C++ runtime is on my machine? If so, how do "they" do it?

(To preemptively address the peanut gallery: I realize I could just use a package manager to install Eclipse. I'm asking about the case where a program isn't specifically tailored for my machine.)

I noticed that the SWT FAQ explains, "SWT uses JNI to interact with the native widgets in the operating system. The SWT JNI libraries must be compiled for the windowing system, operating system and hardware architecture of interest."

That makes me think, "Then how is Eclipse able to make a one-size-fits-all installer for Linux?" (Maybe if I simply tried using one of these installers, all would become clear. But sometimes it's better to just ask your betters.)

I'm trying to understand how Java projects that use the JNI deal with C++ ABI compatibility issues. I asked a similar question a few days ago, and haven't heard much yet ( Is the Java Native Interface (JNI) affected by C++ ABI compatibility issues? ). I figured an Eclipse expert might be able to give me some guidance, since Eclipse might have to deal with similar issues.

Just to be clear: It seems like Java processes basically cannot use C++ libraries. The Java process needs a C++ runtime. If a shared library needs an incompatible C++ runtime ... well, you probably get the idea by now.

(Thanks for reading all of this.)

Community
  • 1
  • 1
John V.
  • 403
  • 3
  • 8
  • C++ ABI **are** a nightmare on Windows too (different versions of MSVC, plus debug vs release issues, plus odd flags like iterator debugging). Runtime versions are too. – Alexandre C. Jan 06 '12 at 17:29
  • Alexandre: Good point. I will change "Let's ignore Windows for now, since C++ ABI compatibility is not an issue on that platform." To simply "Let's ignore Windows for now." – John V. Jan 06 '12 at 17:42
  • Probably the same way everyone makes c++ portable: `extern "C"` for every exported function? Afaik you can't call c++ functions from JNI anyhow (I'd say for exactly the ABI reason but who knows) so you get that as a side effect of having to use C functions already. – Voo Jan 06 '12 at 18:00

1 Answers1

0

My guess is what when they build it they statically link the c++ standard library into the application (or provide their own copy of the dynamic library during with the installer) Then the glibc is the only other dynamic library and thats easier to deal with (though still has that challenges associated with it).

One way you could test this would be to install the package (on linux) then run the ldd utility against the executable and see what it links against.

alanxz
  • 1,966
  • 15
  • 17