Results 1 to 5 of 5

Thread: Cannot resolve the symbols from a custom dll

  1. #1
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Cannot resolve the symbols from a custom dll

    Hello,
    I am very close to tear all my hairs out. I have been trying to resolve the functions from my custom dll but so far, no luck.

    Here is the template I use:

    Qt Code:
    1. QLibrary library("E:/QT_works/myDll.dll");
    2.  
    3. if(library.load())
    4. qDebug()<<"Loading done";
    5.  
    6.  
    7. typedef void (*MyPrototype)();
    8. MyPrototype myFunction = (MyPrototype) myLib.resolve("myFunction");
    9. if (myFunction)
    10. myFunction();
    To copy to clipboard, switch view to plain text mode 

    Loading is successful. However, symbols cannot be resolved.
    I used debugger and after the myLib.resolve step, the following error appears on the window where name and values are shown;

    bq. errorString "Cannot resolve symbol "myFunction" in E:/QT_works/myDll.dll: The specified procedure could not be found." QString

    I also used
    Qt Code:
    1. HINSTANCE hDLLFeX;
    2. hDLLFeX=LoadLibrary(L"myDll.dll");
    3. if(hDLLFeX)
    4. qDebug()<<"LOAD SUCCESSFUL";
    5.  
    6. MyPrototype myFunction = (MyPrototype) GetProcAddress(hDLLFeX, "myFunction");
    To copy to clipboard, switch view to plain text mode 
    Both return a null pointer.
    It's obvious that I cannot find the function declared in the library source file, but I guess I used correct syntax when declaring my function. What I used was

    Qt Code:
    1. extern "C" {
    2. ...
    3. void myFunction(int,int)
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 
    It's good to mention that the same dll was used by someone else earlier in VS 6.0.

    I also downloaded DependencyWalker and check the names of the functions inside myDll.dll. I noticed something which seemed to be interesting. The name of the function which dependencywalker shows is _Z8myFunctionPd, _Z8 in front and Pd at the end of the function. I guess it shouldn't be a problem.
    I am not sure if I should resolve the symbols by the name shown in dependencywalker or the original name declared in extern "C".

    I am hoping someone might be able to help me.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Cannot resolve the symbols from a custom dll

    did you export the class/function ?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: Cannot resolve the symbols from a custom dll

    I am using the below in the common API.h file.
    #ifndef FEX_API_H
    #define FEX_API_H

    #ifdef WIN32
    #ifndef DLLEXPORT
    #define DLLEXPORT __declspec(dllexport)
    #endif
    #endif

    extern "C" {

    ...
    ....
    typedef int DLLEXPORT (*MyPrototype )(double*);

    }

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Cannot resolve the symbols from a custom dll

    Well,
    Qt Code:
    1. int MyPrototype(double *);
    To copy to clipboard, switch view to plain text mode 
    is not the same as
    Qt Code:
    1. void MyPrototype();
    To copy to clipboard, switch view to plain text mode 
    which you are calling.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: Cannot resolve the symbols from a custom dll

    Hello,
    I used identifiers in Qlibrary template so sorry for the mistake I made. I have found the solution.
    I had directly converted the code from VS 6.0 so .def file is used to add the export directive to the object file. However, in the newer versions of compilers such as MinGW and VS 11, __declspec(dllexport) is used to add the export directive automatically. I just added declared the functions with __declspec(dllexport) keyword and problem is solved.
    Thank you. I really appreciate the helpful comments.

Similar Threads

  1. Scatter plot with custom symbols
    By jcox23 in forum Qwt
    Replies: 4
    Last Post: 5th February 2010, 12:54
  2. How to resolve qbyteA[5] = qbyteB?
    By hiuao in forum Qt Programming
    Replies: 9
    Last Post: 12th January 2008, 13:33
  3. Unable to resolve the IP address. ( Qt 3.)
    By joseph in forum Qt Programming
    Replies: 18
    Last Post: 5th July 2007, 12:02
  4. Can somebody resolve this issue???
    By im_rajya in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 10:37
  5. Auto resolve in QFileDialog
    By Levon Nikoghosyan in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 11:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.