I'm new to ffi. But I successfully used dart-ffi with functions call.
Now, I'd like to use a C++ object in dart ffi. I don't know if it is possible, but I tried like this.
The prototypes of constructor call are :
function_dart = lib
.lookup<NativeFunction<function_native>>("constructor_function")
.asFunction();
But I've got :
Failed to lookup symbol <constructor_function>
, where I tried constructor function with :
constructor_function
class::constructor_function
class::constructor_function(args)
I did nm -gDC <lib>
, and I can see the constructor.
Help !
edit 1 : @Botje, @Richard-Heap
I'm trying to use the VideoCapture instance from OpenCV.
I have followed the instructions from Botje's answer.
So I created a lib, like this :
bind.hpp :
#ifndef BIND_HPP
# define BIND_HPP
#include <opencv2/videoio.hpp>
extern "C" {
cv::VideoCapture *cvCreateVideoCapture(char *filename, int apiPreference);
}
#endif
bind.cpp :
#include "bind.hpp"
cv::VideoCapture *createVideoCapture(char *filename, int apiPreference) {
return new cv::VideoCapture(filename, apiPreference);
}
The commands I use to compile :
g++ -c bind.cpp -lopencv -o bind.o
g++ bind.o -shared -o bind.so
I get : dart: symbol lookup error: ./lib/src/bind.so: undefined symbol: _ZN2cv12VideoCaptureC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi
Next step, is to use a method of VideoCapture instance.
Thank you