1

我开始将 NCReport 整合到我的应用程序中,但我总是遇到这些错误

她是我的 .pro 文件

#-------------------------------------------------
#
# Project created by QtCreator 2013-08-14T17:44:33
#
#-------------------------------------------------


QT       += core gui sql xml

greaterThan(QT_MAJOR_VERSION, 4){
QT += widgets printsupport
DEFINES += HAVE_QT5
}



TARGET = gestionstock6
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    produit.cpp \
    customqtablewidget.cpp \
    customdelegatecombobox.cpp \
    customproxy.cpp \
    client.cpp \
    bondelivraison.cpp \
    chercherproduit.cpp \
    chercherclientproduitwidget.cpp \
    fournisseur.cpp \
    chercherfournisseur.cpp \
    vente.cpp

    HEADERS  += mainwindow.h \
    customqtablewidget.h \
    customdelegatecombobox.h \
    customproxy.h \
    client.h \
    bondelivraison.h \
    chercherproduit.h \
    produit.h  \
    produit.h \
    produit.h \
    chercherclientproduitwidget.h \
    fournisseur.h \
    chercherfournisseur.h \
    vente.h

FORMS    += mainwindow.ui \
    produit.ui \
    client.ui \
    bondelivraison.ui \
    chercherproduit.ui \
    chercherclientproduitwidget.ui \
    fournisseur.ui \
    chercherfournisseur.ui \
    vente.ui


       INCLUDEPATH = "E:\apprendreQt\gestionstock6\includes\include"

       LIBS = "E:\apprendreQt\gestionstock6\includes\lib\NCReport2.lib"

这是我对 ncreport 的实现

void Vente::on_pushButton_4_clicked()
{
    NCReport *report = new NCReport(this);
    report->reset(true);
    report->setReportFile("E:\apprendreQt\build-gestionstock6-Desktop_Qt_5_1_0_MinGW_32bit-Debug\reports\abdeu.xml");

    report->runReportToQtPreview();
}

当我编译我的项目文件时,出现以下错误

我已经尝试了很多次但同样的问题

E:\apprendreQt\gestionstock6\vente.cpp:222: erreur : undefined reference to `_imp___ZN8NCReport5resetEb'

E:\apprendreQt\gestionstock6\vente.cpp:223: erreur : undefined reference to `_imp___ZN8NCReport13setReportFileERK7QString'

E:\apprendreQt\gestionstock6\vente.cpp:225: erreur : undefined reference to `_imp___ZN8NCReport20runReportToQtPreviewEv'

collect2.exe:-1: erreur : error: ld returned 1 exit status
4

1 回答 1

0

看起来您正在使用不兼容的库。

这告诉我您正在使用 MinGW 编译器

report->setReportFile("E:\apprendreQt\build-gestionstock6-Desktop_Qt_5_1_0_MinGW_32bit-Debug\reports\abdeu.xml");

但在您的.pro文件中,您包含来自不同编译器的静态链接库(很可能是 MS Visual Studio)

LIBS = "E:\apprendreQt\gestionstock6\includes\lib\NCReport2.lib"

MinGW 的库应该有一个.a扩展,而不是.lib一个。

不仅如此,您还错误地使用了 LIBS 变量。对于 MinGW 编译器,您应该分别指定库路径(with -L)和库本身(with -l)。

您可以在单独的行上执行此操作:

LIBS += "-L/path/to/libraries"
LIBS += "-lmylibrary.a"

或在一行中:

LIBS += "-L/path/to/libraries -lmylibrary.a"
于 2013-09-01T11:38:11.923 回答