There is no language that can do this well because the C++ standard does not specify a name mangling scheme. Because of this, different compilers are free to mangle names differently, and there's no consistent way to link to C++ binaries.
The reason so many things can link to C is because C has simple and consistent linkage. A function foo
is called foo
in the object file. Likewise, things can link to Fortran reasonably well because foo
is one of foo
, FOO
, foo_
, or foo__
.
This is why there are so many wrapper generators for C++ objects (SWIG, Boost.Python, SIP, etc.). They define an interface as a set of C calls precisely because that makes things easy to link against.
Something else to keep in mind is whether you really want to link directly to C++ libraries. Many wrapper generators provide a lot of policy options when you generate wrappers. Remember, C calls boil down to just functions, but C++ calls typically have a lot of OO semantics you'll need to navigate around. You need to specify how your C++ objects should be garbage collected in the host language, how things get copied, where vptrs are, how objects are laid out, where objects get allocated, and all the subtle differences between the host language's object model and that of C++.
I know it sounds ideal to just link to a C++ library and be done with it, but it's not that simple, and you're going to want more than just direct linkage in the end anyway.