bimetek / QUSB

Qt wrapper classes for LibUSB 1.0
GNU Lesser General Public License v3.0
21 stars 16 forks source link

Building MinGW 32 #8

Open gurmaaan opened 7 years ago

gurmaaan commented 7 years ago
C:\...\QUSB-master\src\bulkio.cpp:49: ошибка: invalid conversion from 'void (*)(libusb_transfer*)' to 'libusb_transfer_cb_fn {aka void (__attribute__((__stdcall__)) *)(libusb_transfer*)}' [-fpermissive]
         );
         ^ 
uranusjr commented 7 years ago

Can you provide some context before and after this error output? It’s difficult (if not impossible) to work with just ); indicating the location in source…

cdwijs commented 5 years ago

Hi, I have the problem too. I get the following compile output: g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DQUSB_LIBRARY -DQT_QML_DEBUG -DQT_CORE_LIB -I../../QUSB/src -I. -IC:/Qt/5.11.1/mingw53_32/include -IC:/Qt/5.11.1/mingw53_32/include/QtCore -I../build/src -IC:/Qt/5.11.1/mingw53_32/mkspecs/win32-g++ -o ../build/src/bulkio.o ../../QUSB/src/bulkio.cpp ../../QUSB/src/bulkio.cpp: In member function 'virtual void QUSB::BulkIOPrivate::fill(libusb_transfer*, int, uchar*, int)': ../../QUSB/src/bulkio.cpp:49:9: error: invalid conversion from 'void (*)(libusb_transfer*)' to 'libusb_transfer_cb_fn {aka void (__attribute__((__stdcall__)) *)(libusb_transfer*)}' [-fpermissive] ); ^ In file included from ../../QUSB/src/clibusb:26:0, from ../../QUSB/src/bulkio.cpp:22: C:/Qt/5.11.1/mingw53_32/include/libusb-1.0/libusb.h:1545:20: note: initializing argument 6 of 'void libusb_fill_bulk_transfer(libusb_transfer*, libusb_device_handle*, unsigned char, unsigned char*, int, libusb_transfer_cb_fn, void*, unsigned int)' static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,

The offending line is line 40-49 in bulkio.cpp

My versions: Windows 7 SP1 QT 5.11.1 mingw53_32 libusb 1.0.22

PS, I have to change QString::fromAscii to QString::fromLatin1 in handle.cpp line 195 to compile with Qt 5.11.1

Cheers, Cedric

uranusjr commented 5 years ago

Looks like MinGW requires an explicit cast on line 46 for IOPrivate::transferCallback to libusb_transfer_cb_fn. Maybe add an & before it would fix that. @cdwijs would you mind trying this out and sending a pull request if that works?

cdwijs commented 5 years ago

Hi there, This compiles, but I have another problem: 'class BulkIOPrivate : public IOPrivate { Q_DECLARE_PUBLIC(BulkIO)

public: BulkIOPrivate(IO q, Handle handle, int endpoint) : IOPrivate(q, handle, endpoint) {}

virtual void fill(libusb_transfer *tran, int flag, uchar *buf, int len)
{
    libusb_fill_bulk_transfer(
        tran,
        this->handle->rawhandle(),
        flag | this->endpoint,
        buf,
        len,
        reinterpret_cast<libusb_transfer_cb_fn>(IOPrivate::transferCallback),
        this,
        0
    );
}

};`

g++ -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,../lib/libqusb.a -o ../lib/qusb.dll ../build/src/device.o ../build/src/handle.o ../build/src/io.o ../build/src/bulkio.o ../build/src/io_p.o ../build/src/eventhandler.o ../build/src/moc_io.o ../build/src/moc_bulkio.o ../build/src/moc_eventhandler.o -lusb-1.0 -LC:/Qt/5.11.1/mingw53_32/lib C:/Qt/5.11.1/mingw53_32/lib/libQt5Cored.a c:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lusb-1.0 collect2.exe: error: ld returned 1 exit status Makefile.Debug:90: recipe for target '../lib/qusb.dll' failed mingw32-make[2]: Leaving directory 'o:/Elektronica Jobs/3957953 Prototype apneu/SCPI programs/build-qusb-Desktop_Qt_5_11_1_MinGW_32bit-Debug/src' Makefile:36: recipe for target 'debug' failed mingw32-make[1]: Leaving directory 'o:/Elektronica Jobs/3957953 Prototype apneu/SCPI programs/build-qusb-Desktop_Qt_5_11_1_MinGW_32bit-Debug/src' mingw32-make[2]: *** [../lib/qusb.dll] Error 1 mingw32-make[1]: *** [debug] Error 2 Makefile:40: recipe for target 'sub-src-make_first' failed mingw32-make: *** [sub-src-make_first] Error 2 08:35:26: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project qusb (kit: Desktop Qt 5.11.1 MinGW 32bit) When executing step "Make" 08:35:26: Elapsed time: 00:34.

uranusjr commented 5 years ago

The linker cannot locate your libusb-1.0 binary. You’ll need to supply the path to the linker (there is an option for that)