I open .dll with the help of QLibrary (I check, it opens successfully). Then, before adding this .dll to the header

#ifdef Q_WS_WIN #define MY_EXPORT __declspec(dllexport) #else #define MY_EXPORT #endif 

(as stated in the manual), and, adding in the header, to the functions that I want to call

 extern "C" MY_EXPORT __declspec(dllexport) 

For example: enter image description here I try, in fact, to call them this way:

  Geocom_orig=new QLibrary("GeoComS2K.dll"); Geocom_orig->load(); qDebug()<<Geocom_orig->isLoaded(); typedef GRC_TYPE (*MyComInit)(); MyComInit ComInit=(MyComInit) Geocom_orig->resolve("COM_Init"); qDebug()<<Geocom_orig->errorString(); if(ComInit) qDebug()<<"OK"; int returnedCode=ComInit(); 

errorString () displays the error:

enter image description here

What could be the problem? It seems that everything is done correctly ... The only thing that seems to me strange is that it displays "COM_Init \" as an undefined symbol.

UPD: I apologize, did not translate the console encoding:

enter image description here

Actually, I do not really understand, is he really looking for exactly "COM_Init \"?

    1 answer 1

    I came across a practical advice to try opening .dll using the utility http://dependencywalker.com/ (here's the topic itself https://forum.qt.io/topic/8820/solved-cannot-resolve-the-symbols-from-a -custom-dll / 2 ). With the help of which you can find out the structure of the .dll, and at the same time the names of functions that can be called, because they may have a different name from what is specified in the header. In this case, the COM_Init function had such an interesting name: enter image description here

    I would be very grateful if the comments explain why she and some other functions have such strange names.

    • one
      This is the C ++ name format for the characters, called C ++ name mangling, this system is adopted because overloading functions in C ++ implies the possibility of the existence of more than one function with the same name, which would make proper character resolution impossible. - Vladimir Pavluk
    • In other words, this library contains characters not in the ā€œCā€ format, but in the C ++ format. - Vladimir Pavluk
    • @Vladimir Pavluk, thanks. In this case, is there any more native method to find out the name of the function to export? - bronstein87
    • perhaps it exists, but I know nothing about it. The problem is that different compilers do it differently. - Vladimir Pavluk