简体   繁体   English

库链接错误:未定义引用_imp__

[英]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.

相关问题 无法在Qt5中将UniDAQ库与MinGW4.8.2链接(未定义对`_imp__的引用) - Fail to link UniDAQ library with MinGW4.8.2 in Qt5 (undefined reference to `_imp__) 将HDF5库链接到Visual C ++ DLL项目:未解析的外部符号__imp __ * - Linking HDF5 library into Visual C++ DLL project: unresolved external symbol __imp__* 错误:对 _imp_*** 的未定义引用 - Error: undefined reference to _imp_*** 链接到静态库时未定义的引用错误 - Undefined Reference Error When Linking to Static Library CMake 链接错误,找到库但“未定义引用” - CMake linking error, finding library but “undefined reference” 静态链接到libzbar.a时出错:未定义引用`_imp__GetACP @ 0' - Error when statically-linking to libzbar.a: undefined reference to `_imp__GetACP@0' 链接问题与libcrypto:未定义引用`__imp__CertFreeCertificateContext' - Linking issue with libcrypto: undefined reference to `__imp__CertFreeCertificateContext' 将GLEW与MinGW64链接-对&#39;__imp_glewExperimental&#39;和&#39;__imp___glewGenVertexArrays&#39;的未定义引用 - linking GLEW with MinGW64 - undefined reference to `__imp_glewExperimental' and `__imp___glewGenVertexArrays' 链接错误:未定义的引用 - Linking error: undefined reference 传递库链接中的未定义引用 - Undefined reference in transitive library linking
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM