Sapera++ API 与 Qt 未定义引用 '_imp__ZN11SapLocation

Sapera++ API with Qt undefined reference to '_imp__ZN11SapLocation

本文关键字:imp ZN11SapLocation 引用 API Qt 未定义 Sapera++      更新时间:2023-10-16

我正在使用Sapera++(相机的API)在Qt中编写代码。这是我的 .pro 文件(我在其中定义库和路径):

#-------------------------------------------------
#
# Project created by QtCreator 2017-11-08T10:35:39
#
#-------------------------------------------------
QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test2
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += 
        main.cpp 
        mainwindow.cpp
HEADERS += 
        mainwindow.h
FORMS += 
        mainwindow.ui
INCLUDEPATH += 'C:Program FilesTeledyne DALSASaperaClassesBasic'
INCLUDEPATH += 'C:Program FilesTeledyne DALSASaperaInclude'
INCLUDEPATH += 'C:Program FilesTeledyne DALSASaperaLib'
LIBS += 'C:Program FilesTeledyne DALSASaperaLibWin64SapClassBasic.lib'

类\基本文件夹包含所有头文件。

主窗口.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "SapClassBasic.h"
#include "SapAcquisition.h"
HWND disp;
bool success;
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    disp = (HWND) ui->graphicsView->winId();
    SapAcquisition *pAcq = new SapAcquisition(SapLocation("Xtium-CLHS_PX4_1", 0), "test.ccf");
    SapBuffer *pBuffer = new SapBuffer(1, pAcq);
    SapView *pView = new SapView(pBuffer, disp);
}
MainWindow::~MainWindow()
{
    delete ui;
}

运行代码后,出现以下错误:

In function `ZN10MainWindowC2EP7QWidget':
D:Qt-Projectsbuild-test2-Desktop_Qt_5_9_2_MinGW_32bit-Debug/../test2/mainwindow.cpp:18: undefined reference to `_imp___ZN11SapLocationC1EPKci'
D:Qt-Projectsbuild-test2-Desktop_Qt_5_9_2_MinGW_32bit-Debug/../test2/mainwindow.cpp:18: undefined reference to `_imp___ZN14SapAcquisitionC1E11SapLocationPKcyPFvP18SapAcqCallbackInfoEPv'
D:Qt-Projectsbuild-test2-Desktop_Qt_5_9_2_MinGW_32bit-Debug/../test2/mainwindow.cpp:19: undefined reference to `_imp___ZN11SapLocationC1Eii'
D:Qt-Projectsbuild-test2-Desktop_Qt_5_9_2_MinGW_32bit-Debug/../test2/mainwindow.cpp:19: undefined reference to `_imp___ZN9SapBufferC1EiP11SapXferNodei11SapLocation'
D:Qt-Projectsbuild-test2-Desktop_Qt_5_9_2_MinGW_32bit-Debug/../test2/mainwindow.cpp:20: undefined reference to `_imp___ZN7SapViewC1EP9SapBufferP6HWND__PFvP19SapViewCallbackInfoEPv'
debug/mainwindow.o: In function `ZN11SapLocationD1Ev':
C:/Program Files/Teledyne DALSA/Sapera/Classes/Basic/SapManager.h:38: undefined reference to `_imp___ZTV11SapLocation'
collect2.exe: error: ld returned 1 exit status

似乎有一些关于我的"Sap"库的东西没有定义,尽管我已经将所有内容都包含在 .pro 文件中。

解决方案:我已经从其网站下载并安装了MSVC15版本的Qt,还安装了Visual Studio 2015 Microsoft(因此也将安装Microsoft Visual c ++编译器)。然后在qt编译器中,我添加了Microsoft Visual c ++编译器作为我的主编译器。现在它:)工作

在项目文件 (.pro) 中添加如下库:

LIBS += -L[path to library] -l[library]

LIBS += -L"C:Program FilesTeledyne DALSASaperaLibWin64" -lSapClassBasic.lib