Exporting functions with _declspec(dllexport)

Hi,

I have a DLL library and I export classes from this library. All classes and their method are properly exported and can be seen in "dumpbin /symbols mydll.dll" output. I use the standard _declspec(dllexport) and _declspec(dllimport) approach.

All classes lie under a namespace like:

namespace MyDLL
{
  MYDLL_EXPORT void init() ; // Implemented in MyDLL.cpp
  class MYDLL_EXPORT MyClass // Methods Implemented in MyDLL.cpp
  {
  }
}


I have another project which tries to link with the DLL and the linker can not resolve the MyDLL::init() function.

The output of "dumpbin /symbols MyDLL.dll" also doesn't show a init function. But all class functions are properly exported.

I am not sure anymore what else I need to do. Any ideas

Thanks in advance,
Devrim


Answer this question

Exporting functions with _declspec(dllexport)

  • Alexey A. Vasilyev

    C++ is a language were you have control over everything. So there are no automatic includes. And because it only does what the user/programmer says it is very user freindly. SCNR



  • Ihavethesamequestion

    try dumpbin /exports MyDLL.dll.  Maybe it's exported using C++ linkage instead of C linkage. 

    Try:

    extern "C" MYDLL_EXPORT void init()


  • Thomas K Knudsen

    Thanks for the suggestion. I have tried it and it didn't work. So I started at looking at other things.

    I found the problem, unbelievable. The cpp was for some reason not including its own header file. I have added the include and now all exports are there.

    C++. Ain't it programmer friendly :(

  • Exporting functions with _declspec(dllexport)