Results 1 to 9 of 9

Thread: Link as a dll

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Question Link as a dll

    Hi all,

    I am embarrassed to ask, but I cannot seem to work out how to link a project as a dll. I created a new project in Qt Creator 1.2.1, using Qt 4.5.1, and chose for it to be a C++ shared library. I just went ahead and built the library, and found that the resulting shared library had the name libMyProject.a. What I need is a .dll, rather than a .a file. How do I go about getting this. I am used to Visual Studio which would just put out a dll file.

    Thanks for your help...

  2. #2
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Link as a dll

    Forgot to say that I'm using Qt on Windows Vista. I know, I should be on UNIX, but that's not always possible in this world.

    Hoping that someone can help me with this probably stupid dilemma. Or was that a dilemma of stupidity.

    Bruce

  3. #3
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Link as a dll

    Please post your .pro-file of the project. It should have something like this in it:

    Qt Code:
    1. TEMPLATE = lib
    2. CONFIG += shared
    To copy to clipboard, switch view to plain text mode 

    If the second line is missing, it will create a static library (.a).
    It's nice to be important but it's more important to be nice.

  4. #4
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Wink Re: Link as a dll

    Hey axeljaeger, thanks for the info. I didn't have the CONFIG += shared bit. Added that and it now wants to create a dll.

    The new issue is that I have a hundred warnings (and some of them errors) such as:

    undefined reference to `_imp___ZN10QTabWidgetC1EP7QWidget'

    This is happening in 3 different cpp files, and to all of the warning/error instances have to do with Qt files, such as QString, QObject, QTabWidget, QBoxLayout, etc. Some others look like objects/variables that were defined under the covers, like FlagLocation, found in the munged string `_imp___Z13qFlagLocationPKc'. I assume that I have to add some flag to my linker command line call, but not sure what it would be.

    My .pro file with your change is now as follows:

    ------------------MyLib.pro Start--------------------
    # -------------------------------------------------
    # Project created by QtCreator 2009-10-14T13:19:12
    # -------------------------------------------------
    TARGET = MyLib
    TEMPLATE = lib
    CONFIG += qt \
    shared # <- added this as suggested
    QT += gui \
    core \
    network \
    xml
    # DEFINES += BUILD_DLL # <- had this in there before but took it out since you didn't mention it
    SOURCES += <list of sources goes here>
    HEADERS += <list of headers goes here>
    FORMS += src/aboutwindow.ui \
    src/mylib.ui
    LIBS += -L../lib \
    -lidasclient \
    INCLUDEPATH += ../../../idasclient/include
    OTHER_FILES += src/res/MyLib.rc
    RESOURCES += pictures.qrc
    RC_FILE = src/res/MyLib.rc
    ------------------MyLib.pro End--------------------

    Again, I looked around for an solution to this before reposting. Thanks again for the information you gave, and for any help you can give with this new issue...
    Bruce

  5. #5
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Unhappy Re: Link as a dll

    So I should have given you this information too. The last line that was running when the compile errored out, plus a handful of the first errors tha popped up, are as follows:

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -Wl,--out-implib,debug\libPaulUI.a -o debug\PaulUI.dll object_script.PaulUI.Debug -L"c:\Qt\qt-win-opensource-src-4.5.1\lib" debug\Azigo_res.o -L../lib -lidasclient -lxdi -lftk -lmsvcp80 -lmsvcr80 -lQtXmld -lQtGuid -lQtNetworkd -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCored -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
    ./debug\passwords.o: In function `ZN9Passwords15initPanelWidgetEv':
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:17: undefined reference to `_imp___ZN10QTabWidgetC1EP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:20: undefined reference to `_imp___ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE '
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:21: undefined reference to `_imp___ZN11QVBoxLayoutC1Ev'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:22: undefined reference to `_imp___ZN11QHBoxLayoutC1Ev'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:23: undefined reference to `_imp___ZN12QTableWidgetC1EiiP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:24: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:25: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:26: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:29: undefined reference to `_imp___ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE '
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:30: undefined reference to `_imp___ZN11QVBoxLayoutC1Ev'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:31: undefined reference to `_imp___ZN11QHBoxLayoutC1Ev'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:32: undefined reference to `_imp___ZN12QTableWidgetC1EiiP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:33: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:34: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:37: undefined reference to `_imp___ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE '
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:38: undefined reference to `_imp___ZN11QVBoxLayoutC1Ev'
    C:/Users/bruce/Projects/Qt/Azigo/PaulUI/src/passwords.cpp:39: undefined reference to `_imp___ZN11QHBoxLayoutC1Ev'

    Hope that gives some more insight...
    Bruce

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Link as a dll

    Every Qt-lib it tries to link against has a d as the last letter. This means it tries to link agains the debug-version of that library. All other libraries are not debug-libraries so I have my doubts that this will work. Anyway, are these debug-versions realy around on your system?
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Link as a dll

    Yes, these debug versions:

    libQtCored.a
    libQtGuid.a
    libQtNetworkd.a
    libQtXmld.a

    are in the same lib directory as the non-debug versions (those with the same exact names except no d at the end).

    So you are thinking that I should be linking with debug the whole way? I'm just not sure why that would be different building a dll than a straight .a library. I have built the .a library in debug mode, using the same non-debug versions of the 3 extra libraries being added in, and it built well, and I was able to call it from another driver program and run it, windows widgets and all.

    Bruce

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Link as a dll

    I think you cannot mix debug and non debug libraries on windows.
    It's nice to be important but it's more important to be nice.

  9. #9
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Link as a dll

    So I changed to a release build, cleaned the project, ran qmake to make sure, and then restarted the build, and got the same exact results. Hmmmm. Definitely stumped here...
    Bruce


Similar Threads

  1. Replies: 4
    Last Post: 24th November 2007, 13:33
  2. QLabel link color
    By dragon in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2007, 07:09
  3. ignore following link in anchorClicked()
    By jh in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2006, 16:33
  4. LINK : fatal error LNK1181: can't open 'delayimp.lib'
    By fcamlar in forum Installation and Deployment
    Replies: 10
    Last Post: 7th July 2006, 13:04
  5. Text Browser Link Question
    By taylor34 in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2006, 19:54

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.