🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SharedLibraries

Started by
0 comments, last by FloViel 22 years, 10 months ago
Is it possible to create C++ SharedLibraries under Linux?? I''ve tried it and creation worked but when I wanted to load a function via "dlsym" it failed with the error: "Symbol not found". When I use C as the programming language everything works fine. What am I doing wrong?
Visit:http://www.evildawncrew.comAll things which are worth beeing done, are worth beeing donw well.
Advertisement
The problem you get is that C++ is prone to name-mangling. In other words, it doesn''t export a function foo, but rather a function "foo@VQAAH" or something like that. C++ does that in order to be type-safe - those additional characters somehow represent the argument and return value types.

To prevent that, simply prefix your function declarations with extern "C", or put all your function headers in something like this:

  #if defined(__cplusplus)extern "C" {#endif// Your function decls go here...#if defined(__cplusplus)};#endif  


cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement