0

I've used dlopen(), dlsym() and friends in the past to load dynamic libraries manually at run-time - but that was in C. In C++ I would expect a somewhat higher-level-of-abstraction API, or at least - something which transparently takes care of name mangling for you, rather than only having to stick to extern "C" freestanding functions.

Well, according to the C++ dlopen mini-howto, my expectations should be let down. Apparently it's just the POSIX API and nothing else. ... except that that document was last updated in 2006. That's the best I could find Googling.

So is that how things stand today still? In other words, have better/easier/nicer idiomatic ways of working with shared objects been devised over the past decade?

Note: I realize the C++ language standard doesn't quite address this (if at all), so I'm asking about what people use in practice.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 2
    There is no `dlopen` in either C or C++ standards so it's not very clear what your expectations are based upon. `dlopen` is a POSIX function. – n. m. could be an AI Jun 18 '16 at 20:49
  • @n.m.: Is this better? – einpoklum Jun 18 '16 at 21:06
  • 2
    There's no real way to "transparently take care of name mangling", however, there's no need to stick to `extern "C"` freestanding functions. You only need to call one such function once, get it to return a C++ object, and unfurl your C++ API from there. – n. m. could be an AI Jun 18 '16 at 22:10

1 Answers1

1

Martin Olivier is currently working on a C++ shared library dynamic loading library (sorry, tongue-twister): dylib, with some support and advice from myself :-P

Specifically, he is taking on the challenge of name mangling. Too bad more people aren't involved who can invest the time to contribute additional name mangling conventions (e.g. MVSC).

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Did you see https://stackoverflow.com/a/64077113/15416 by any chance? – MSalters Jun 20 '22 at 23:42
  • @MSalters: I have not seen it. Actually, looking at, it could potentially be redone based on my own [constexpr type_name](https://stackoverflow.com/a/64490578/1593077) (which is multi-compiler). – einpoklum Jun 21 '22 at 11:20
  • @MSalters: Ok, guess not. But that's certainly useful. – einpoklum Jun 21 '22 at 11:33