Dependencies missing after DLL compilation
-
@UvQtcYZJuD7J5VW7 said in Dependencies missing after DLL compilation:
QString path = "C:/Users/xxxxx/Desktop/xxxxx/Qt/build-ProtoDLL2-Desktop_Qt_6_2_2_MinGW_32_bit-Release/release/ProtoDLL2.dll"; a.addLibraryPath(path);
I would change this to:
QFileInfo f("C:/Users/xxxxx/Desktop/xxxxx/Qt/build-ProtoDLL2-Desktop_Qt_6_2_2_MinGW_32_bit-Release/release/ProtoDLL2.dll"); a.addLibraryPath(f.absoluteDir());
-
@KroMignon I just applied the changes you suggested but it doesn't seem to affect the loading of the DLL. I get the same error.
-
@UvQtcYZJuD7J5VW7 said in Dependencies missing after DLL compilation:
I just applied the changes you suggested but it doesn't seem to affect the loading of the DLL. I get the same error.
AFAIK,
QLibrary::isLibrary()
only check if the filename is a valid name for a library, not if the file exists.
Just in case of the path is wrong:QFileInfo f("C:/Users/xxxxx/Desktop/xxxxx/Qt/build-ProtoDLL2-Desktop_Qt_6_2_2_MinGW_32_bit-Release/release/ProtoDLL2.dll"); if(!f.exists()) { qDebug() << "File" << f. fileName() << "not found!"; } a.addLibraryPath(f.absoluteDir());
-
This post is deleted!
-
@KroMignon Here the entire code of main.cpp
When I run my app, I don't have the message that the DLL is non existing.
And I replaceabsoluteDir()
byfilePath()
because Qt Creator say Calling 'absoluteDir' with incomplete return type 'QDir'#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); QLibrary lib; QFileInfo f("C:/Users/xxxxx/Desktop/xxxxx/Qt/build-ProtoDLL2-Desktop_Qt_6_2_2_MinGW_32_bit-Release/release/ProtoDLL2.dll"); if(!f.exists()){ qDebug() << "file" << f.fileName() << "not found !"; } a.addLibraryPath(f.absoluteDir()); if(QLibrary::isLibrary(f.filePath())) { lib.setFileName(f.filePath()); lib.load(); if(lib.isLoaded()) qDebug() << "Ok\n"; else qDebug() << "Error " << lib.errorString() << "\n"; } else qDebug() << "Not a library\n"; return a.exec(); }
Thanks for your help
-
@UvQtcYZJuD7J5VW7 said in Dependencies missing after DLL compilation:
I want to generate a shared library (DLL) with Qt functions (QWebsocket in particular) in 32 bits. This generated DLL will be used in LabView project (32 bits) with Call Library Function Node (CLFN).
Before we go too far down this path, may I ask why you want to use QWebSocket instead of a native LabVIEW WebSocket library? https://www.vipm.io/search/?q=websocket
But now, I still can't access to my DLL with LabView.
Why not? What do you see when you configure the Call Library Function Node to use the DLL?
Calling 'absoluteDir' with incomplete return type 'QDir'
You need to
#include <QDir>
QString path = "C:/Users/xxxxx/Desktop/xxxxx/Qt/build-ProtoDLL2-Desktop_Qt_6_2_2_MinGW_32_bit-Release/release/ProtoDLL2.dll"; a.addLibraryPath(path);
addLibraryPath()
is for adding a folder, not a DLL. See https://doc.qt.io/qt-6/qcoreapplication.html#addLibraryPathSo, now, if I want to share my DLL, I need to give libgcc and libstd.
Correct. And if your DLL uses Qt functions, then you must also provide the Qt DLLs.
More importantly, note that:
- The Qt features might depend on some plugins (for example,
tls\qopensslbackend.dll
). You need to callQCoreApplication::addLibraryPath()
to specify where to find the plugins. - Many Qt classes, including QWebSocket, require a running event loop (in other words,
QCoreApplication::exec()
must be active). However,exec()
blocks (doesn't return) until youquit()
. - Many Qt classes are not thread-safe. However, LabVIEW is implicitly multithreaded and can call your function from any thread.
This means your DLL must start its own background
std::thread
and guarantee that the Qt class methods are called in in the correct thread. - The Qt features might depend on some plugins (for example,
-
@JKSH said in Dependencies missing after DLL compilation:
Before we go too far down this path, may I ask why you want to use QWebSocket instead of a native LabVIEW WebSocket library? https://www.vipm.io/search/?q=websocket
Of course, I prefer to use QWebSocket because on WebSocket connection, I serialize my data. My serializer doesn't work with LabView, it works with C++ Class, so for the next feature, it's better according to me to use QWebSocket.
Why not? What do you see when you configure the Call Library Function Node to use the DLL?
Here is my error screen from LabView :
I just put this code on my diagram :
With this configuration :
You need to
#include <QDir>
Obviously, I really need to familiarize myself with Qt ! But Qt Creator return me this error (in editor mode) :
no viable conversion from 'QDir' to 'const QString'
Thanks for your help, I continue to work on your last comment.
-
@UvQtcYZJuD7J5VW7 said in Dependencies missing after DLL compilation:
I prefer to use QWebSocket because on WebSocket connection, I serialize my data. My serializer doesn't work with LabView, it works with C++ Class, so for the next feature, it's better according to me to use QWebSocket.
I think it's easier to serialize your data in C++, pass the serialized byte array to LabVIEW, then write to a WebSocket in LabVIEW.
The stuff that I mentioned in my previous post (running an event loop in a background thread) is quite complex.
Obviously, I really need to familiarize myself with Qt ! But Qt Creator return me this error (in editor mode) :
no viable conversion from 'QDir' to 'const QString'
QDir is not a QString, so you can't pass QDir to a function that expects a QString. You need to convert your QDir data to a QString first (see https://doc.qt.io/qt-5/qdir.html for your options)
Here is my error screen from LabView :
You should have gotten a more detailed error message when you first selected the DLL in the configuration dialog.
Delete the node, then re-create it. Pay attention to all messages that appear.
-
@JKSH said in Dependencies missing after DLL compilation:
I think it's easier to serialize your data in C++, pass the serialized byte array to LabVIEW, then write to a WebSocket in LabVIEW.
Yes, I would also like to be able to do this but I use Protocol Buffers, I don't see how I could provide the classes generated by my serializer. I had thought of putting generated class by protobuf into a DLL and make the connection in the DLL. Labview just call DLL function (like connect, emit, disconnect...).
Otherwise I could programming the entire program in Qt and so I will not have the need to use a DLL.You should have gotten a more detailed error message when you first selected the DLL in the configuration dialog.
Unfortunately, LabView is not very talkative. This is the only error message I get. I have already recreated the node.
-
@UvQtcYZJuD7J5VW7 said in Dependencies missing after DLL compilation:
Unfortunately, LabView is not very talkative. This is the only error message I get. I have already recreated the node.
Ah, check the dependencies of the DLLs that you deployed. For example, libgcc_s_dw2-1.dll depends on other DLLs too.
Otherwise I could programming the entire program in Qt and so I will not have the need to use a DLL.
If you can do everything in 1 language, that makes life a lot easier.