[英]Library linking error: undefined reference to _imp__
I can't figure out how to link FTDI library in my Qt project. 我无法弄清楚如何在我的Qt项目中链接FTDI库。 I copied ftd2xx.h file to my project directory.
我将ftd2xx.h文件复制到我的项目目录中。 The file I want to link is dll: ftd2xx.lib which is stored in F:\\Workspace\\qt\\libs\\ftdi\\amd64
我要链接的文件是dll:ftd2xx.lib,它存储在F:\\ Workspace \\ qt \\ libs \\ ftdi \\ amd64中
I get error: 我收到错误:
release/testftdi.o:testftdi.cpp:(.text+0x6f8): undefined reference to `_imp__FT_Open@8'
collect2.exe: error: ld returned 1 exit status
I have QtWidget application with one PushButton: 我有一个PushButton的QtWidget应用程序:
TestFtdi.pro file: TestFtdi.pro文件:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestFtdi
TEMPLATE = app
LIBS += -L"F:\Workspace\qt\libs\ftdi\amd64" -lftd2xx
INCLUDEPATH += f:/Workspace/qt/libs/ftdi/amd64
SOURCES += main.cpp\
testftdi.cpp
HEADERS += testftdi.h
FORMS += testftdi.ui
main.cpp file: main.cpp文件:
#include "testftdi.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
TestFtdi w;
w.show();
return a.exec();
}
testftdi.h file: testftdi.h文件:
#ifndef TESTFTDI_H
#define TESTFTDI_H
#include <QMainWindow>
namespace Ui {
class TestFtdi;
}
class TestFtdi : public QMainWindow
{
Q_OBJECT
public:
explicit TestFtdi(QWidget *parent = 0);
~TestFtdi();
private slots:
void on_pushButton_clicked();
private:
Ui::TestFtdi *ui;
};
#endif // TESTFTDI_H
testftdi.cpp file: testftdi.cpp文件:
#include "testftdi.h"
#include "ui_testftdi.h"
#include <QDebug>
#include "windows.h"
#include "ftd2xx.h"
TestFtdi::TestFtdi(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TestFtdi)
{
ui->setupUi(this);
}
TestFtdi::~TestFtdi()
{
delete ui;
}
void TestFtdi::on_pushButton_clicked()
{
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) { // FT_Open failed
qDebug() << "FT_Open failed";
}
}
The compiler command looks in this situation like this: 编译器命令在这种情况下看起来像这样:
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\TestFtdi.exe release/main.o release/testftdi.o release/moc_testftdi.o -lmingw32 -LC:/Qt/5.5/mingw492_32/lib -lqtmain -lshell32 -LF:\Workspace\qt\libs\ftdi\Static\amd64 -lftd2xx -lQt5Widgets -lQt5Gui -lQt5Core
Could you help me with this? 你能帮帮我吗?
My guess is, compiler might be looking for ftd2xx
rather than ftd2xx.lib
(file name is ftd2xx.lib.dll, right?). 我的猜测是,编译器可能正在寻找
ftd2xx
而不是ftd2xx.lib
(文件名是ftd2xx.lib.dll,对吧?)。 Have you tried changing the LIBS line to 您是否尝试过将LIBS行更改为
LIBS += -L"F:\Workspace\qt\libs\ftdi\amd64" -lftd2xx.lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.