About how to use the API correctly



  • Yesterday I want to use a new CCD's API to do some job,I find it has the .lib,.dll and .h file.But some thing very interesting happened:It tells me following mistake when I want to use the Initiation function of API in .cpp of Mainwindow.

    C:\Users\bycy0\Desktop\Qt File\smartekvision2_demo\mainwindow.cpp:9: error: undefined reference to `gige::InitGigEVisionAPI()'
    collect2.exe:-1: error: error: ld returned 1 exit status
    

    It seems me didn't use the lib correctly,however,when I create some API class in .h file of Mainwindow,it didn't tell any errors.I use the ‘Add new library’ to add my lib.

    Here is the code:

    .pro:
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = smartekvision2_demo
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    win32: LIBS += -L$$PWD/../../../../../GigEVisionSDK/lib/ -lGigEVisionSDK_32bit
    
    INCLUDEPATH += $$PWD/../../../../../GigEVisionSDK/include
    DEPENDPATH += $$PWD/../../../../../GigEVisionSDK/include
    
    mainwindow.h:
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include "gige_cpp/GigEVisionSDK.h"
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
        initialize();
        gige::IDevice device;                    //It could pass through compilation!!
    };
    
    #endif // MAINWINDOW_H
    
    mainwindow.cpp:
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        gige::InitGigEVisionAPI();                //It is wrong here!!
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    

  • Moderators

    @MartinChan What compiler do you use and which compiler was used to build this library?
    I'm asking because on windows you cannot mix binaries built with different compilers (even not different versions of same compiler).



  • @jsulm My compiler is MinGW 5.7.0. My lib file is here

    I searched for solutions before,and I have used MSVC2013 compiler to have a test before,but unfortunately,it failed too.


  • Moderators

    @MartinChan You need to find out what compiler was used to build the library


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.