Results 1 to 12 of 12

Thread: D2XX Drivers for FTDI examples

  1. #1

    Default D2XX Drivers for FTDI examples

    Hi

    I am looking for some examples how to use ftd2xx.lib in QT.


    Regards
    Artur

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: D2XX Drivers for FTDI examples

    If you want to use a a library in your C++ program then that is between you, your compiler, and your linker. Qt is just another library that may be watching from the sidelines.

  3. #3

    Default Re: D2XX Drivers for FTDI examples

    How I attach external library:

    - Create new QTWidgets
    - press right button of mouse on name of project
    - chose Add library
    - chose external library
    - chose file with library (ftd2xx.lib)
    - to *.pro is attached the following block
    Qt Code:
    1. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386/ -lftd2xx
    2. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386/ -lftd2xxd
    3.  
    4. INCLUDEPATH += $$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386
    5. DEPENDPATH += $$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386
    To copy to clipboard, switch view to plain text mode 


    after compiling I have the errors:

    - error: and: No such file or directory
    - error: Settings/IE25USER/Pulpit/CDM: No such file or directory
    - error: v2.12.06: No such file or directory
    - error: WHQL: No such file or directory
    - error: Certified/Static/i386/: No such file or directory

    I do not know why I have the erros.

    Regards
    Artur

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: D2XX Drivers for FTDI examples

    You have no quotes around these paths but they contain spaces.

    Also the beginning of those paths look wrong. It looks like your paths are in directories on the C drive, but you are specifying paths that are relative to the directory the .pro file is in.

    So
    1) make those paths start with the drive letter
    2) put them in quotes so they can be recognized as one string, not as a series of separate arguments.

    Cheers,
    _

  5. #5

    Default Re: D2XX Drivers for FTDI examples

    Hi

    I changed path of the lib and everything is ok.

    Now I can chose Static library or dynamic library.

    In static catalogue there is only one file *.lib.
    In dynamic catalogue there are : 5 files *.dll , 2 files *.sys , 1 files *.lib

    Which option is better to chose ?

    In main catalogoue there is one file *.h where should I copy it ?

    I have never added external library and I do not know what is the right way.


    Regards
    Artur

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: D2XX Drivers for FTDI examples

    If you link using a dynamic library (DLL), then you have to deploy the DLLs along with your application. If you link to the static library, then you do not need to deploy anything extra with your app. If you are developing a commercial app and your library is licensed under LGPL, then usually you must use DLL linkage. If you are writing an open source app or do not intend to distribute it, then you can choose whatever form of linking you want.

    You do not have to copy the .h file - leave it where it is. It is used only during compiling and has nothing to do with *running* your app. However, like the LIBS entry, you must configure your Qt .pro file so it knows where to look for it by adding the directory to INCLUDEPATH. And, like your original problem with LIBS, the INCLUDEPATH name needs to be edited to fix the errors.

  7. #7

    Default Re: D2XX Drivers for FTDI examples

    Currently my code in *.pro file

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2015-09-23T16:48:13
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = FTDI
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp
    17.  
    18. HEADERS += mainwindow.h
    19.  
    20. FORMS += mainwindow.ui
    21.  
    22. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xx
    23. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xxd
    24. else:unix: LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xx
    25.  
    26. INCLUDEPATH += $$PWD/../../d2xx
    27. DEPENDPATH += $$PWD/../../d2xx
    To copy to clipboard, switch view to plain text mode 


    Everything was addaded by creator of adding library. I showed him where is library and header to my library but the function from the lib are not visible in the mainwindow.c.
    If I copy my header file to catalogue where is project and include it in the mainwindow.c then all function are visible

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QDebug>
    4. #include <ftd2xx.h>
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. }
    12.  
    13. MainWindow::~MainWindow()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void MainWindow::on_pushButton_clicked()
    19. {
    20.  
    21. FT_STATUS ftStatus;
    22. unsigned long numDevs;
    23. // create the device information list
    24. ftStatus = FT_CreateDeviceInfoList(&numDevs);
    25.  
    26. if (ftStatus == FT_OK) {
    27.  
    28. qDebug () << numDevs;
    29. // printf("Number of devices is %d \n",numDevs);
    30. }
    31. else {
    32. // FT_CreateDeviceInfoList failed
    33. }
    34.  
    35.  
    36.  
    37. }
    To copy to clipboard, switch view to plain text mode 

    but It seems that it should be visible without including

    Regards
    Artur
    Last edited by arturs; 23rd September 2015 at 16:20.

  8. #8
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: D2XX Drivers for FTDI examples

    h file contains among other things a list of library functions. This is the information necessary for the compiler. These are the basics of C / C ++.

  9. #9

    Default Re: D2XX Drivers for FTDI examples

    Yes. I know

    During adding external library It is necessary to write path for headers. Why ?
    When does the QT use it ?

  10. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: D2XX Drivers for FTDI examples

    Quote Originally Posted by arturs View Post
    During adding external library It is necessary to write path for headers. Why ?
    The header files define the interface to the library for your compiler to use to check your usage of the library and generate appropriate object code to access it.
    When does the QT use it ?
    Your compiler uses an include path to find header files, and your linker uses a library search path and library name to locate and connect libraries to your object code. The qmake tool can be used to write a Makefile to pass appropriate arguments to your compiler (INCLUDEPATH) and linker (LIBS) to make this happen. The Qt library uses neither the headers nor libraries of your arbitrary third party library.
    Last edited by ChrisW67; 23rd September 2015 at 21:11. Reason: spelling corrections

  11. #11

    Default Re: D2XX Drivers for FTDI examples

    Thank you for explanation.

    If I want to use all function from the library I should include ftd2xx.h in mainwindow.c and copy header file for example to catalogue with project

    Am I right ?

  12. #12
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: D2XX Drivers for FTDI examples

    Quote Originally Posted by arturs View Post
    Thank you for explanation.

    If I want to use all function from the library I should include ftd2xx.h in mainwindow.c
    Yes.
    and copy header file for example to catalogue with project

    Am I right ?
    No, just add proper directory to INCLUDE directive in pro file

Similar Threads

  1. Replies: 1
    Last Post: 7th March 2013, 00:30
  2. QT SQL drivers
    By eslam in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2012, 06:59
  3. Replies: 0
    Last Post: 29th December 2011, 21:36
  4. Does anyone have drivers to MySQL for QT 4.7.4
    By TomASS in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2011, 23:14
  5. SQL Drivers Distribution
    By kandalf in forum Installation and Deployment
    Replies: 1
    Last Post: 12th January 2009, 09:17

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.