Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] DLL library loading problems.

[SOLVED] DLL library loading problems.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    der.ule
    wrote on last edited by
    #1

    Hi

    I've been trying to load a DLL in Qt for a while, but I keep having problems while doing it (this in WinXP). The DLL comes with its respecte LIB file, therefore I'm just using a line in the project file as follows:

    @LIBS += D:/QT/testOPCLibCmd/WTclient.lib@

    When I run the mock project (just calling a function from the library and printing some COUTs) sometimes it goes without problems and if it runs, when I change something to the codes (such as adding another COUT statement), I get an error such as "testOPCLibCmd.exe exited with code -1073741515".

    If then, I change the library definition to:

    @LIBS += -LD:/QT/testOPCLibCmd
    LIBS += -lWTclient.lib@

    and try to recompile, it works again ... until I modify my code, then I get an error

    @:: error: cannot find -lWTclient.lib
    :: error: collect2: ld returned 1 exit status@

    And it continues like that, therefore I would like to as if anyone has a suggestion of what may be the problem ? The library works without a problems in VC++ , so I guess is just my ignorance of some detail, I'm posting below the toy code that I'm using to reproduce the problem.

    Thanks

    @
    int main(int argc, char *argv[])
    {
    cout<<WTclientRevision()<<endl; //Using the library to show the revision number
    cout<<WTclientCoInit()<<endl; //Initializing code from library
    WTclientCoUninit(); //Uninitialize library code
    cin.get();
    cout<<"problems"; //Taking this statment in an out breaks/fix library loading
    return 0;
    }
    @

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Try omitting the .lib extension:

      @LIBS += -lWTclient@

      qmake is probably smart enough to handle the .lib extension, but ye never know. The error code suggests that you need to add the required dll to the search path (which is either PATH + current directory afaik).

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        der.ule
        wrote on last edited by
        #3

        I knew it was a little detail that scaped me ! The .DLL is together with the .LIB file in the directory project, therefore was very strange that sometimes "it was there" and others was not.

        I changes as you suggested the library loading in the .PRO file to:

        @
        LIBS += -LD:\QT\testOPCLibCmd
        LIBS += -lWTclient
        @

        And have been able to run my project and make some changes, so far has not failed to recompile as before. I also wonder if it had something to do with the forward slashes.

        Thanks a lot Franzk!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved