Unsolved 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
give me about 126000 issues
stray '\220' in program
stray '\3' in program
stray '@' in program
stray '\4' in program
stray '\377' in program
i've searched in google and read about possible codification problem (UTF16?)
can anyone help me to find a solution??
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.
Also 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
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 ?
@mrjj yes i'have .dll file in the project folder
if i remove:
no issues was detected
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
its 1000000000% incorrect. :)
dll's manual say:
Connect to Robot Controller
char *hostname )
IP address or hostname of the controller
cont_no : Connected controller number
Negative value : Error code ( refer to chapter 9)
Connect to robot controller. After you call this API, you can use other APIs.
Something like this:
int NC=0; QString HostName = "192.168.1.144" QbyteArray IP = HostName.toLocal8Bit().constData(); int krnx_open(int NC, char *IP);
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 ?
@mrjj Yes, sorry i've forgot this line..
no viable conversion from 'QByteArray' to 'char *'
how can i solve??
Yes, first controller must be zero
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)
LNK1120: 1 extern not solved
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 ?
@SGaist Yes 32 bit
- 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 yet
if i try to compile with MinGW 32 bit
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):
It would be nice to know which version of VS they have used. Starting with 2017 they now have backward compatibility.