About how to use the API correctly
-
wrote on 19 Dec 2016, 02:24 last edited by
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; }
-
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; }
@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). -
@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).wrote on 19 Dec 2016, 08:18 last edited by@jsulm My compiler is MinGW 5.7.0. My lib file is
I searched for solutions before,and I have used MSVC2013 compiler to have a test before,but unfortunately,it failed too.
-
@jsulm My compiler is MinGW 5.7.0. My lib file is
I searched for solutions before,and I have used MSVC2013 compiler to have a test before,but unfortunately,it failed too.
@MartinChan You need to find out what compiler was used to build the library
1/4