I'm building a Qt/C++ app. This App must connect to an android device through MTP. during a mtp copy, I had to provide a C callback to the MTP API (C-only)
I have declared this callback is below:
DeviceMngr.cpp
int fileprogress(const uint64_t sent, const uint64_t total, void const * const data) {
int percent = (sent * 100) / total;
if (Transfer_Cancelled == true)
return 1;
return 0;
}
DeviceMngr.h
extern bool Transfer_Cancelled;
extern "C" {
int fileprogress(const uint64_t sent, const uint64_t total, void const * const data);
}
And it's called in the method below:
uint32_t DeviceMngr::CreateFile(QString filename, uint32_t parent_id) {
...
ret = LIBMTP_Send_File_From_File(Device->device, strdup(AbsolutePath), genfile, fileprogress, NULL);
...
The Transfer_Cancelled is used :
void DeviceMngr::CancelTransfer() {
Transfer_Cancelled = true;
}
and
DeviceMngr::DeviceMngr()
{
...
Transfer_Cancelled = false;
}
And also in the method instantiation to make sure it's init to false.
Here is the issue:
Undefined symbols for architecture x86_64:
"_Transfer_Cancelled", referenced from:
DeviceMngr::DeviceMngr() in devicemngr.o
DeviceMngr::CreateFile(QString, unsigned int) in devicemngr.o
_fileprogress in devicemngr.o
DeviceMngr::CancelTransfer() in devicemngr.o
ld: symbol(s) not found for architecture x86_64
TransferCancel is only define DeviceMngr.c and any other place.
Any idea ?