PDA

View Full Version : Tring to link against a DLL



feraudyh
10th December 2013, 11:03
Hi there,
I got a fingerprint scanner together with the driver, header files and a couple of files ftrscanAPI.lib and ftrscanAPI.dll. Presumably these have been built with MSVC.
I'm working in Windows 7.
My installation of Qt Creator uses Mingw and gcc but since I do have MSVC 2008 I suppose I could configure it to use MSVC, but I'd rather not for the time being.
Anyway I have tried a test application which shows that the scanner runs fine.
But trying to make use of the functions in a Qt C+ program is another story.
I added
LIBS += -LD:\\dev\\CplusPlus\\DemoFutronics\\ftrScanAPI
to the project file, but nothing doing, I get error messages at compile time
like

D:\dev\CplusPlus\DemoFutronics\mainwindow.cpp:-1: error: undefined reference to `ftrScanOpenDevice@0'
D:\dev\CplusPlus\DemoFutronics\mainwindow.cpp:-1: error: undefined reference to `ftrScanGetImageSize@8'
...
:-1: error: release/mainwindow.o: bad reloc address 0x2bc in section `.gcc_except_table'


Look at the last one, it's really obscure.
I dont know what I'm doing wrong.
My strategy is now to load at runtime, I am making good progress, but it's unfortunate to have to go this way.

anda_skoa
10th December 2013, 16:14
Your LIBS line currently only specifies a search path, it is missing the actual library, i.e. -lnameoflibrary

Cheers,
_

feraudyh
10th December 2013, 18:32
The path of the import library is
D:\\dev\\CplusPlus\\DemoFutronics\\ftrScanAPI.lib
the path of the DLL is
D:\\dev\\CplusPlus\\DemoFutronics\\ftrScanAPI.dll

ChrisW67
10th December 2013, 21:30
So you should have:


LIBS += -LD:/dev/CplusPlus/DemoFutronics -lftrScanAPI

-L specifies a directory (among many) that should be searched by the linker for requested libraries
-l specifies the name of specific libraries that are requested to satisfy missing symbols in the program.

I have used the forward slash in the path to avoid the annoyance of escaping back slashes. Qmake does the right thing with these.

feraudyh
11th December 2013, 09:19
Thanks, I tried that, but I still get messages like this

D:\dev\CplusPlus\DemoFutronics\mainwindow.cpp:199: error: undefined reference to `ftrScanOpenDevice@0'
etcetera

By the way dynamic loading with QLibrary works, but i have resolve each of the function names and use function pointers.