I am having trouble making a program to interact with an FTDI chip. I don't know how much information I can give in regards to the model number of the chip.
I am trying to use the API FTDI provides to communicate with the chip I have. I am using Qt Creator for the program and this is my first time using it. All of the examples I have found use include "ftd2xx.h"
. Well, I have tried so many ways to get it working. I have manually typed in the directory of the ftd2xx.lib, moved the files to the project directory and chose "Internal Library", used the original directory and chose "External Library", and chosen the "System Library".
The only method that gives me a different error is when I include the driver package files in the project directory and just include the header file with or without the LIBS += ...
. Even then I get 393 errors saying NAME does not name a type
, NAME not declared in scope
, etc.
How do I create a Qt Creator C++ project that recognizes the ftd2xx.lib
and lets me use the functions from ftd2xx.h
?
EDIT: I am using the Windows 64bit driver package. In my frustration, I forgot I should include these important details.
EDIT2: Code below.
#include <QCoreApplication>
#include <iostream>
#include "ftd2xx.h"
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
cout << "test" << endl;
return a.exec();
}
#-------------------------------------------------
#
# Project created by QtCreator 2013-10-04T16:31:18
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -lftd2xx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -lftd2xxd
else:unix: LIBS += -L$$PWD/ -lftd2xx
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
All of that is followed by more NAME does not name a type
errors.
The ftd2xx header has a lot of Windows types in it so you need to include windows.h before including the ftdi header.
The .lib file is a DLL link library which provides the linker information required to make use of the DLL at runtime. The following compiles and runs using g++:
#include <windows.h>
#include <stdio.h>
#include <ftd2xx.h>
int main(int argc, char *argv[])
{
DWORD version = 0;
FT_STATUS status = FT_GetLibraryVersion(&version);
printf("version %ld\n", version);
return (status == FT_OK) ? 0 : 1;
}
Compiled using:
g++ -Wall -Idriver -o check.exe check.cpp driver/i386/ftd2xx.lib
where the driver
folder contains the distributed FTDI windows driver package. The -lftd2xx
will have the linker searching for something called libftd2xx.a so just explicitly provide the .lib filename.