Results 1 to 6 of 6

Thread: Using A .DLL File?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2012
    Posts
    32
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Using A .DLL File?

    Hello There,

    I am trying to use a .dll file i created in my project. My question is: how would i go about doing this?

    I have already tried Project >> Add Existing Files >> and then selecting the .dll
    Then I used:
    #include "MyDLL/mydll.h"

    But this gives the undefined reference error.

    Any help would be much appreciated. Thanks in advance,
    Matt

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using A .DLL File?

    See the qmake manual for declaring other libraries and the LIBS variable.

  3. #3
    Join Date
    Oct 2012
    Posts
    32
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using A .DLL File?

    Quote Originally Posted by ChrisW67 View Post
    See the qmake manual for declaring other libraries and the LIBS variable.
    It appears to give me this error when i try to call a function from the .dll:

    undefined reference to `_imp___ZN7SkyFallC1Ev'

    Any ideas?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using A .DLL File?

    The linker cannot find the library to link your application to. See the LIBS docs I pointed you at.

  5. #5
    Join Date
    Oct 2012
    Posts
    32
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Using A .DLL File?

    Quote Originally Posted by ChrisW67 View Post
    The linker cannot find the library to link your application to. See the LIBS docs I pointed you at.
    Thanks man, the docs have really helped. However, i have decided to simply link the .h files to the project by using INCLUDEPATH and then linking it to the folder with the .h and .cpp files.

    Even after doing this, however, i get the same goddamn error. Any ideas?

    Thanks,
    Matt

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using A .DLL File?

    You don't "link" a header file or link to a folder. You link compiled object files (e.g. main.o or floober.obj) and libraries (e.g. x.lib or libx.a) together to make the final executable. This magic is done by a thing called a linker. Qmake, when used correctly, sets all this up for you based on the rules you give it in the PRO file. The linker is given the object files that result from compiling all the SOURCES. It is also given the names of libraries (collections of object files) to link with through -l (lowercase-L) options in the LIBS variable. If the libraries are not in the standard locations then you can supply extra paths to be searched by giving -L options in LIBS.

    Linking has nothing to do with includes or INCLUDEPATH: that is used in the preceding compilation stage.

    If you have built a DLL project into folder /some/path/X then there will be project.dll and project.lib/libproject.a (exact names depend on compiler type) in that folder. To link your application object files with that library you use:
    Qt Code:
    1. LIBS += -L/some/path -lproject
    To copy to clipboard, switch view to plain text mode 

    If you simply want to put some sources in a subfolder but build them directly into your project then you do that with:
    Qt Code:
    1. HEADERS += subfolder/thingy.h subfolder/another.h
    2. SOURCES += subfolder/thingy.cpp subfolder/another.cpp
    To copy to clipboard, switch view to plain text mode 
    The LIBS variable is not required because these files will be compiled into individual object files and linked automatically by the Makefile that qmake produces.

Similar Threads

  1. Replies: 3
    Last Post: 1st November 2010, 16:33
  2. Replies: 4
    Last Post: 9th May 2010, 16:18
  3. Replies: 3
    Last Post: 28th March 2009, 15:37
  4. Replies: 0
    Last Post: 6th March 2009, 08:19
  5. Replies: 3
    Last Post: 25th May 2007, 07:49

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
  •  
Qt is a trademark of The Qt Company.