) I'm currently developing a project under Qt Creator 4.3.1 which needs an external library to use a key-lock hardware device.
The device comes with a CD with the libraries libkfunc64.so and libkfunc64.a (and the 32 bits versions) presumably compiled for C with gcc. I already tried the libraries in a dummy program to check if they work, and they do.
But when I add the important chunk of code into the Qt project it spits the following error
[...] error: undefined reference to `KFUNC(unsigned int, unsigned int, unsigned int, unsigned int)'
I've already tried to include the library
- by coping the libraries to the system directories and simply including the following line in the
.profileLIBS += -lkfunc64
by using relative paths to the libs in the
.profileLIBS += -L$$PWD/../build-project/ -lkfunc64
INCLUDEPATH += $$PWD/../build-Qmetrics-Desktop-Debug DEPENDPATH += $$PWD/../build-Qmetrics-Desktop-Debug
# PRE_TARGETDEPS += $$PWD/../build-Qmetrics-Desktop-Debug/libkfunc64.a
but it keeps showing this error when trying to (re)build it. I've read almost every subject about this issue on the internet but non of them fix this problem.
This is the code for main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QMessageBox>
// Key-lock stuff ----------
#define ValidateCode1 0X488B
#define ValidateCode2 0XFEE2
#define ValidateCode3 0XEF90
#define ClientIDCode1 0xB862
#define ClientIDCode2 0x54CB
#define ReadCode1 0X1772
#define ReadCode2 0XC4E6
#define ReadCode3 0XBCF8
extern unsigned long KFUNC(unsigned, unsigned, unsigned, unsigned);
unsigned RotateLeft(unsigned, int);
void KTASK(unsigned, unsigned, unsigned, unsigned);
unsigned short ReturnValue1, ReturnValue2;
// -------------------------
int main(int argc, char *argv[])
{
KTASK(1, ValidateCode1, ValidateCode2, ValidateCode3);
KTASK(RotateLeft(ReturnValue1, ReturnValue2 & 7) ^ ReadCode3 ^ ReturnValue2, RotateLeft(ReturnValue2, ReturnValue1 & 15), ReturnValue1 ^ ReturnValue2, 0);
if ((ReturnValue1 == ClientIDCode1) && (ReturnValue2 == ClientIDCode2))
{
QApplication app(argc, argv);
MainWindow w;
w.showFullScreen();
return app.exec();
}
else
{
QMessageBox msgBox;
msgBox.setText("Wrong or missing key-lock!");
return msgBox.exec();
}
}
unsigned RotateLeft(unsigned Target, int Counts)
{
int i;
static unsigned LocalTarget, HighBit;
LocalTarget = Target;
for (i=0; i<Counts; i++)
{
HighBit = LocalTarget & 0X8000;
LocalTarget = (LocalTarget << 1) + (HighBit >> 15);
}
LocalTarget = LocalTarget & 0XFFFF; /* For 32 bit integers */
return (LocalTarget);
}
void KTASK(unsigned CommandCode, unsigned Argument2, unsigned Argument3, unsigned Argument4)
{
unsigned long int ReturnValue;
ReturnValue = KFUNC(CommandCode, Argument2, Argument3, Argument4); // <--- this is the only function that is used from the external library
ReturnValue1 = (unsigned) (ReturnValue & 0XFFFF);
ReturnValue2 = (unsigned) (ReturnValue >> 16);
}
And the (relevant part of the) .pro file is as follow
# Adds OpenCV, DC1394 and Keylok libraries
unix {
CONFIG += link_pkgconfig
PKGCONFIG += opencv
LIBS += -ldc1394 -lkfunc64
}
I really don't know what to do :'(