Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. About how to use the API correctly
QtWS25 Last Chance

About how to use the API correctly

Scheduled Pinned Locked Moved Unsolved General and Desktop
libdll
4 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MartinChan
    wrote on 19 Dec 2016, 02:24 last edited by
    #1

    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;
    }
    
    
    J 1 Reply Last reply 19 Dec 2016, 05:15
    0
    • M MartinChan
      19 Dec 2016, 02:24

      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;
      }
      
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 19 Dec 2016, 05:15 last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 19 Dec 2016, 08:18
      0
      • J jsulm
        19 Dec 2016, 05:15

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

        M Offline
        M Offline
        MartinChan
        wrote on 19 Dec 2016, 08:18 last edited by
        #3

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

        J 1 Reply Last reply 19 Dec 2016, 08:44
        0
        • M MartinChan
          19 Dec 2016, 08:18

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 19 Dec 2016, 08:44 last edited by
          #4

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          4/4

          19 Dec 2016, 08:44

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved