Results 1 to 5 of 5

Thread: Tring to link against a DLL

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Tring to link against a DLL

    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
    Qt Code:
    1. LIBS += -LD:\\dev\\CplusPlus\\DemoFutronics\\ftrScanAPI
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by feraudyh; 10th December 2013 at 13:51.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Tring to link against a DLL

    Your LIBS line currently only specifies a search path, it is missing the actual library, i.e. -lnameoflibrary

    Cheers,
    _

  3. #3
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tring to link against a DLL

    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

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tring to link against a DLL

    So you should have:
    Qt Code:
    1. LIBS += -LD:/dev/CplusPlus/DemoFutronics -lftrScanAPI
    To copy to clipboard, switch view to plain text mode 
    -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.

  5. #5
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tring to link against a DLL

    Thanks, I tried that, but I still get messages like this
    Qt Code:
    1. D:\dev\CplusPlus\DemoFutronics\mainwindow.cpp:199: error: undefined reference to `ftrScanOpenDevice@0'
    To copy to clipboard, switch view to plain text mode 
    etcetera

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

Similar Threads

  1. Link for SDK 1.2.1 for Mac
    By mtnbiker66 in forum Qt Tools
    Replies: 3
    Last Post: 20th December 2012, 16:44
  2. Replies: 11
    Last Post: 5th May 2011, 14:05
  3. How to link a Push Button with a Web link ???
    By prajnaranjan.das in forum Newbie
    Replies: 3
    Last Post: 10th December 2010, 07:25
  4. Link as a dll
    By bmahf in forum Newbie
    Replies: 8
    Last Post: 15th October 2009, 19:21
  5. How I link a dll?
    By brevleq in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2007, 02:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.