0

I am trying to create a wrapper file using SWIG for C++ code and call it in python on raspberry pi Linux platform The C++ code contains uEye IDS camera in built function. I am using QT creator and openCV.

To generate wrapper file I have used source : https://mit-crpg.github.io/OpenMOC/devguide/swig.html and it works fine for normal c++ code. Now when I try generating wrapper for IDS camera I get error: Import error:./filename.so: undefined symbol: is_InitCamera. I am not sure how I am supposed to correct it.

exam.i - Interface file-

%module exam
%{
#define SWIG_FILE_WITH_INIT
#include "exam.h"

%}
%include "exam.h"

exam.h - Header file-

#include <iostream>
#include <ueye.h>
#include <opencv2/opencv.hpp>
double cam (int a);

exam.cpp - Source file -

#include"exam.h"

using namespace std;
double cam(int a)
{

    int nRet = 0;
        int nMemoryId = 0;
        HIDS hCam = a;
        HWND hWndDisplay = 0;



        nRet = is_InitCamera(&hCam, hWndDisplay);
        if (nRet != IS_SUCCESS)
        {
            cout << "ERROR" << endl;
        }
        else
        {
            cout << "Camera initialisation was successful!" << endl << endl;
        }


        // Disables the hCam camera handle and releases the data structures and memory areas taken up by the uEye camera
        nRet = is_ExitCamera(hCam);
        if (nRet == IS_SUCCESS)
        {
            cout << "The camera has been successfully logged off!" << endl << endl;
        }



        system("pause");
        return 1;
}
  • Post your code and your build – possum Aug 31 '20 at 11:43
  • How did you compile your exam.cpp? I bet you forgot to link to the ueye library that provides that function. – Botje Aug 31 '20 at 12:04
  • @Botje Iused following command 1) swig -python -c++ -o exam_wrap.cpp exam.i 2) gcc -c exam.cpp -o exam.o -fpic -std=c++0x 3) gcc -I/usr/include/python3.5 -c exam_wrap.cpp -o exam_wrap.o -fpic -std=c++0x 4) g++ exam_wrap.o exam.o -o _exam.so -shared -Wl,-soname,_exam.so – shubham agarwal Aug 31 '20 at 12:11
  • 2
    Edit your question with that, but you need to link (-l) with the ueye sdk as well. I don't know the library name though. – Botje Aug 31 '20 at 12:15
  • @Botje yes linking was missing. thanks for the help! – shubham agarwal Nov 13 '20 at 12:54

0 Answers0