View Full Version : D2XX Drivers for FTDI examples
arturs
10th September 2015, 21:31
Hi
I am looking for some examples how to use ftd2xx.lib in QT.
Regards
Artur
ChrisW67
11th September 2015, 22:53
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.
arturs
23rd September 2015, 10:27
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
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386/ -lftd2xx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386/ -lftd2xxd
INCLUDEPATH += $$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386
DEPENDPATH += $$PWD/C:/Documents and Settings/IE25USER/Pulpit/CDM v2.12.06 WHQL Certified/Static/i386
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
anda_skoa
23rd September 2015, 10:47
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,
_
arturs
23rd September 2015, 16:08
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
d_stranz
23rd September 2015, 16:55
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.
arturs
23rd September 2015, 17:14
Currently my code in *.pro file
#-------------------------------------------------
#
# Project created by QtCreator 2015-09-23T16:48:13
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FTDI
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xxd
else:unix: LIBS += -L$$PWD/../../d2xx/amd64/ -lftd2xx
INCLUDEPATH += $$PWD/../../d2xx
DEPENDPATH += $$PWD/../../d2xx
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <ftd2xx.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
FT_STATUS ftStatus;
unsigned long numDevs;
// create the device information list
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus == FT_OK) {
qDebug () << numDevs;
// printf("Number of devices is %d \n",numDevs);
}
else {
// FT_CreateDeviceInfoList failed
}
}
but It seems that it should be visible without including
Regards
Artur
Lesiok
23rd September 2015, 19:33
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 ++.
arturs
23rd September 2015, 20:00
Yes. I know
During adding external library It is necessary to write path for headers. Why ?
When does the QT use it ?
ChrisW67
23rd September 2015, 22:11
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.
arturs
23rd September 2015, 22:21
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 ?
Lesiok
24th September 2015, 20:12
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.