News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Qt project using TE_USB_FX2_CyAPI.dll

Started by westrice, September 14, 2012, 08:49:49 PM

Previous topic - Next topic

westrice

Hello Forum,

I want to make a minimal project using Qt 4.8.2 and TE_USB_FX2_CyAPI.dll under Win7x32. I followed the instructions attached to "FilesToImportForApplicationCpp.zip", here:

http://www.trenz-electronic.de/download/d0/Trenz_Electronic/d1/TE-USB-Suite/d2/generation_3/d3/reference_designs/d4/TE_USB_FX2.Cpp.html

I included both CyAPI.h and TE_USB_FX2_CyAPI.h to the project tree and my main.cpp is this:

#include <QApplication>
#include "mainwindow.h"

#include <QDebug>
#include <QString>

#include "TE_USB_FX2_CyAPI.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
   
    int n_cards;
    QString text_integer;
   
    CCyUSBDevice *USBDeviceList = new CCyUSBDevice((HANDLE)0,CYUSBDRV_GUID,true);
    n_cards = TE_USB_FX2_ScanCards(USBDeviceList);
    text_integer = text_integer.setNum(n_cards);
    qDebug() << n_cards << endl;

    return a.exec();
}


I included TE_USB_FX2_CyAPI.dll (32 bit version) in the .pro file under QtCreator as follows:


LIBS += "$BUILD_PATH/TE_USB_FX2_CyAPI.dll"


I got the following error:

TE_USB_FX2_CyAPI.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x2C8

I'm using both Qt and QtCreator compiled with msvc2010 as well.

Any ideas for what is causing the error? Anyone has a minimal project with Qt working?

Horsa

Problem due to wrong library link.

You must use static library TE_USB_FX2_CyAPI.lib.
You can find this lib file in FilesToImportForApplicationCpp\DLL32\Optional\ (it is optional for a non Qt application indeed).

This solves the problem you report.
Search engines report that this is the typical problem experienced by Qt developers trying to use common dynamic DLLs instead of static LIBs.

You must add TE_USB_FX2_CyAPI.lib to C:\Qt\qtcreator-2.5.2\MyProject\TryQtTE\ (or whatever the path to your project is) and leave the TE_USB_FX2_CyAPI.dll DLL.

You must add to your .pro file
LIBS += "C:\Qt\qtcreator-2.5.2\MyProject\TryQtTE\TE_USB_FX2_CyAPI.lib"
(or something similar)
and erase C:\Qt\qtcreator-2.5.2\MyProject\TryQtTE\TE_USB_FX2_CyAPI.dll.




Problem due to CyAPI.lib

The substitution of DLL with LIB is the answer to the problem you report. But I doubt that your program can compile after this solution anyway.

I have observed some problems with CyAPI.lib (the problem is not due to TE_USB_FX2_CyAPI):
LNK2019 unresolved external symbol.

I can affirm this because I have tried to erase
n_cards = TE_USB_FX2_ScanCards(...);
The same LNK2019 errors appear.

I am going to try to compile everything directly under Visual Studio 2010 (maybe some setting is wrong within Qt Creator).

We will contact Cypress and ask for further information about this issue.

westrice

Hi,

I managed to solve my problem installing the Qt Addin http://blog.qt.nokia.com/2012/05/22/qt-4-8-2-and-visual-studio-add-in-1-1-11-released/ and compiling through MSVC2010, there's a lot of compiler and linker options that I couldn't figure out how to include in my .pro file, so maintaining the same options used in the TE_USB_FX2_CyAPI_SampleApplication project I was able to compile and execute my application successfully.

Probably it's possible to make things work with QtCreator but it's necessary to include the appropriate compiler and linker options in the .pro file which is not as simple as it seems.

Hengist

The release of the third generation Trenz Electronic USB FX2 Suite made this post obsolete. Please access current documentation and resources here: TE USB FX2 Suite.