Qt World Summit: Register Today!

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:

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

  • Lifetime Qt Champion

    @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.

  • Lifetime Qt Champion

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

Log in to reply