Results 1 to 4 of 4

Thread: How to Call .dll from Qt5.4

  1. #1
    Join Date
    Jan 2015
    Posts
    35
    Thanks
    20
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default How to Call .dll from Qt5.4

    Hello,

    I started a project call dll from Qt C++.

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by Qt5.4 at Windows 7 32bit
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core
    8. QT -= gui
    9.  
    10. TARGET = CallDll
    11. CONFIG += console
    12. CONFIG -= app_bundle
    13.  
    14. TEMPLATE = app
    15.  
    16.  
    17. SOURCES += main.cpp
    18. LIBS += "C:/Qt-Lessons/CallDll/libzinnia.dll"
    19.  
    20. HEADERS += \
    21. zinnia.h
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QDebug>
    3. #include "zinnia.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication a(argc, argv);
    8.  
    9. zinnia::Recognizer *recognizer = zinnia::Recognizer::create();
    10. if (!recognizer->open("c:/handwriting-zh_CN.model")) {
    11. qDebug() << recognizer->what();
    12.  
    13. }
    14.  
    15. return a.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    I also copied libzinnia.dll to my project, debug, release folders and add LIBS in .pro file

    But when I build project, compiler gave errors :
    undefined reference to ..........

    How can I fix it?

    Thanks
    Last edited by anda_skoa; 19th March 2015 at 13:41. Reason: changed [quote] to [code]

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Call .dll from Qt5.4

    Try to give the path and the name of the library separately
    Qt Code:
    1. LIBS += -L C:/Qt-Lessons/CallDll -llibzinnia
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Jan 2015
    Posts
    35
    Thanks
    20
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: How to Call .dll from Qt5.4

    Thank anda_skoa for your reply.

    But it gives same error. undefined reference to `_imp___ZN6zinnia9Character6createEv'
    I found a project. It's at Linux and Qt 5.1

    LIBS += -L/home/AAbin/source/project -lzinnia
    It used -lzinnia, not -llibzinnia. Is it depend upon dll' file name? or because of different Qt version.
    I think I must put l prefix for dll file name.

    I did not build the dll myself, I got it from http://zinnia.sourceforge.net/ that I am trying to use into my application.
    I used it Qt Creator 3.3.0 and Qt5.4. and mingw491_32.

    How can I fix it. DLL file name is libzinnia.dll.

    I changed and tested many words. But it's not successful. I used at Windows 7

    LIBS += -L c:/project -llibzinnia
    or

    LIBS += "c:/project/libzinnia.dll"

    LIBS += "c:\project\libzinnia.dll"
    Thanks.
    Last edited by binary001; 20th March 2015 at 11:14.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Call .dll from Qt5.4

    Quote Originally Posted by binary001 View Post
    It used -lzinnia, not -llibzinnia. Is it depend upon dll' file name? or because of different Qt version.
    On Linux the lib name is prefixed with "lib" by the compiler, I am pretty sure it isn't on Windows.

    I think I must put l prefix for dll file name.

    Quote Originally Posted by binary001 View Post
    I did not build the dll myself, I got it from http://zinnia.sourceforge.net/ that I am trying to use into my application.
    I used it Qt Creator 3.3.0 and Qt5.4. and mingw491_32.
    You could try building it yourself, it might have been built with a different, incompatible, compiler.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    binary001 (20th March 2015)

Similar Threads

  1. Replies: 6
    Last Post: 3rd December 2012, 07:26
  2. how to call mfc dll in Qt
    By gauravg in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 20:42
  3. how to call mfc dll from Qt
    By gauravg in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2011, 07:18
  4. call a class
    By assismvla in forum Newbie
    Replies: 3
    Last Post: 24th May 2010, 12:57
  5. how to call mfc dll use qt?
    By yunpeng880 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 04:32

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.