many stray errors including dll file
-
Hi to all and thanks in advance for help
i have to monitor an industrial robot (Kawasaki) from my Qt app
Kawasaki send me a dll ( krnx-w32.dll) to comunicate with the robot ( using tcp/ip connection QTcpsocket) but
when i #include the dll#include "krnx-w32.dll"
give me about 126000 issues
for example:
stray '\220' in program
stray '\3' in program
stray '@' in program
stray '\4' in program
stray '\377' in program
etc etc...i've searched in google and read about possible codification problem (UTF16?)
can anyone help me to find a solution?? -
Hi
You don't include a DLL like that. it will then load the binary file and freak out as it's expecting text.
The DLL is like an exe file.You will add lines to the project file to tell it to link to that DLL.
https://doc.qt.io/qt-5/third-party-libraries.htmlAlso if on the windows platform. That DLL MUST be made with same compiler that you use.
You cannot use mingw and it used using visual studio etc.Unless its a C interface DLL. then it might work.
You should ask Kawasaki what compiler if it exports C++ interface to be sure.
For visual studio compiler you might need a LIB file also. -
@mrjj i've already added the library with "Add Library.." menu option
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/./ -lkrnx-w32 else:win32:CONFIG(debug, debug|release):LIBS += -L$$PWD/./ -lkrnx-w32d
was added to .pro file
isn't it correct??
the library is specific for C++ (now i've asked which compiler was used)
and i have both .dll and .lib files -
@TheCipo76
Hi
well it looks ok. (yes its correct syntax wise and path should be valid if you point to the file )
Now do a clean all and run qmake and then build all
tne look in compiler panel and see if it complains about them.so you have the DLL in the project folder ?
So its a visual studio DLL, it seems ?
and you are using visual studio for your app ? -
ok next step is to use any of the functions the DLL provides and see if it will run.
If it really links to the DLL. it should work.Ofc you must remove
#include "wrnx-w32.dll"
its 1000000000% incorrect. :) -
@mrjj ok
dll's manual say:Common API
Connect to Robot Controllerint krnx_Open(
int cont_no,
char *hostname )Parameters
cont_no
Controller number
hostname
IP address or hostname of the controllerReturns
cont_no : Connected controller number
Negative value : Error code ( refer to chapter 9)Description
Connect to robot controller. After you call this API, you can use other APIs.See also
krnx_CloseSomething like this:
int NC=0; QString HostName = "192.168.1.144" QbyteArray IP = HostName.toLocal8Bit().constData(); int krnx_open(int NC, char *IP);
??
And now?? -
@TheCipo76
Call the krnx_open and see if app runs.int krnx_open(int NC, char *IP); <<< this is not calling. but i assume you know that.
krnx_open(NC, IP); // would be calling
and cont_no should be zero ? The first controller is zero ?
-
@TheCipo76 said in many stray errors including dll file:
QByteArray' to 'char *
try
krnx_open(NC, IP.data() ); -
@mrjj OMG:
LNK2019: refer to external symbol "int_cdecl krnx_open(int, char ) (?krnx_open @@YAHHPAD@Z) not solved in the function "public:_thiscall MainWindow::MainWindow(class QWidget) (??0MainWindow@@QAE@PAVWidget@@@Z)
mainwindow.obj
LNK1120: 1 extern not solved
-
Hi,
From the name of the dll I would guess that you have a 32bit version. Is it also the case of the Qt version you are using ?
-
Good, then:
- Which compiler are you using ?
- Which compiler was used for that library ?
-
@SGaist Qt 5.12.5 MSVC 2017 32 bit
C: Microsoft Visual C++ Compiler 15.9.28307.905 (x86)
C++: Microsoft Visual C++ Compiler 15.9.28307.905 (x86)
i've asked to kawasaki which compiler was used to create the dll but they don't reply me yetif i try to compile with MinGW 32 bit
Compiler
C: MinGW 7.3.0 32-bit for C
C++: MinGW 7.3.0 32-bit for C++give me this issue:
undefined reference to krnx_open(int, char*)
-
@SGaist Kawasaki reply:
ā
I've taken a look into the lib file and found a "Microsoft link format", so it should be compatible with Microsoft C++ and maybe also with VS C++.
I hope your customer is able to handle around with dll and lib files. To use the dll file correctly, the lib file needs to be statically linked to the project. Maybe your customer forgot about that. If the lib file is correctly linked usually the compiler should be satisfied with the function calls.
If the above don't work, it is possible to guarantee the compatibility with creating a new lib file out of the dll file by a lib-maker tool of VS. I don't know if Microsoft is providing such a tool and have no experience in this, but I did this a long time ago for another project in a Borland C++ programming environment with a Borland tool.
If your customer needs here there is a link that describes the use a dll file in VS (see the second half of the article):
https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=msvc-160
ā -
It would be nice to know which version of VS they have used. Starting with 2017 they now have backward compatibility.