0

I'm trying to create C# bindings using objective sharpie for the objective c library of OpenCV 3.4 (https://opencv.org/releases.html, precompiled and build from source with extra modules) but without success. Either I'm using the wrong sharpie parameters or something is wrong with the compiled opencv2.framework.

Tools/Versions:

  • Sharpie 3.4.0
  • Iphone11.2 SDK
  • OpenCV 3.4.0 (precompiled and/or successfully build from source with extra modules)

I tried the following sharpie parameters (when current dir contains opencv2.framework):

$ sharpie bind -framework opencv2
$ Done. Exiting with error code 1.
error: opencv2: Umbrella header file does not exist: opencv2.framework/Headers/opencv2.h
$

That is because the umbrella file is Headers/opencv.hpp. So i changed the parameters to:

$ sharpie bind -fx-umbrella opencv2.framework/Headers/opencv.hpp -framework opencv2    
Done. Exiting with error code 1.
error: opencv2: Umbrella header file does not exist: opencv2.framework/Headers/opencv2.h
$

which completely gets ignored in every order.

I also tried many other possibilities like defining only the .a file (in combination with removing included libs with lipo):

$ sharpie bind opencv2.a
Parsing 1 header files...
warning: [SomePath]/opencv2.a: 'linker' input unused [-Wunused-command-line-argument]
warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
warning: argument unused during compilation: '-fno-spell-checking' [-Wunused-command-line-argument]
warning: argument unused during compilation: '-Xclang -detailed-preprocessing-record' [-Wunused-command-line-argument]
error: unable to handle compilation, expected exactly one compiler job in ''
Error while processing [SomePath]/opencv2.a.
Done. Exiting with error code 1.
error: Clang failed to parse input and exited with code 1
$

or addressing the umbrella header directly with:

$ sharpie bind Headers/opencv.hpp

which fails because "opencv2/...hpp" file not found because every included hpp refers to "opencv2/..." structure

  • Have you tried to move temporarily the `Headers` folder to `opencv2.framework`? – Gusman Jan 30 '18 at 14:06
  • I tried but it did not help. In the opencv2.framework directory there is a symbolic link to Versions/A/Headers (Versions/A also contains the .a file) and a symbolic link opencv2 to the .a file (if you have a chance, have a look at the folder structure, link to the package is in my start post) – ConstantLearning Jan 30 '18 at 14:36

1 Answers1

0

The fact is quite subtle in the documentation, however it states that

The -framework option does not allow explicit header files to be passed.

and also that

Under the hood, specifying -framework is just a shortcut.

So instead if you need to specify the umbrella header file you can write the parameters as

sharpie bind opencv2.framework/Headers/opencv.hpp -scope opencv2.framework/Headers -c -F .

This gets the process started but there are a myriad of additional problems ahead. I personally gave up after a day of trying to get sharpie to work with OpenCV, but best of luck to anyone going down that path.

JaanTohver
  • 63
  • 2
  • 8