I am trying to write a shared library using C but need to call some C++ functions. So I have created a shared library containing the required C++ functions. How can I call those function from C code, I tried dlopen() and dlsym() in the C code. It creates handle for the C++ library but can't call the functions.

Recommended Answers

All 3 Replies

I tried declaring c functions in extern but i am getting problems in casting ... is there a way i can call some functions defined in C++ shared library in a C code?

Did you code it like this link ?

c++ classes and their methods are not useable from c. If you want to do that then you will have to create a c++ wrapper that can be called from C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.