PDA

View Full Version : How to Call .dll from Qt5.4



binary001
19th March 2015, 11:44
Hello,

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



#-------------------------------------------------
#
# Project created by Qt5.4 at Windows 7 32bit
#
#-------------------------------------------------

QT += core
QT -= gui

TARGET = CallDll
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app


SOURCES += main.cpp
LIBS += "C:/Qt-Lessons/CallDll/libzinnia.dll"

HEADERS += \
zinnia.h




#include <QCoreApplication>
#include <QDebug>
#include "zinnia.h"

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

zinnia::Recognizer *recognizer = zinnia::Recognizer::create();
if (!recognizer->open("c:/handwriting-zh_CN.model")) {
qDebug() << recognizer->what();

}

return a.exec();
}



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

anda_skoa
19th March 2015, 13:44
Try to give the path and the name of the library separately


LIBS += -L C:/Qt-Lessons/CallDll -llibzinnia


Cheers,
_

binary001
20th March 2015, 10:50
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.

anda_skoa
20th March 2015, 12:28
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.



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,
_