How to call Flutter plugin that uses OpenCV C++ on iOS? - c++

I am working on a Flutter plugin that uses OpenCV to perform image processing for both Android and iOS.
Having followed the official tutorial on binding to native code using dart:ffi and followed this answer on how to use OpenCV 4 in native C++ of Flutter I have a plugin that can be called by a Flutter app and perform OpenCV image processing on Android and I am able to successfully call to, and retrieve the correct results form, my C++ functions, which use OpenCV, when testing the plugin on iOS.
When I call these same functions from a Flutter app on iOS that use the plugin I get the error "Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, ): symbol not found)".
I believe that this issue may be related to an issue noted in this Medium article on Using FFI on Flutter to run native Rust code, in which it suggests:
"XCode will not bundle the library unless it detects explicit usage within the workspace. Since our Dart code calling it is out of the scope of XCode, we need to write a dummy Swift function that makes some fake usage."
I have tried to create a dummy Swift function as suggested above in ios/Classes/.swift but the function is not recognised and the build fails with the error "use of unresolved identifier '<my C++ function name>'".

Related

I'm trying to use native C++ libraries in a MAUI app and cannot get it working for MacOS/iOS

There's a great article here that describes how to use native C++ libraries in Xamarin/C#, and I would assume that this would extend to MAUI: https://learn.microsoft.com/en-us/xamarin/cross-platform/cpp/
I followed these instructions, and put together an end-to-end demo solution of it here: https://github.com/whodges/bindingsample. This does require that you link Visual Studio to a MacBook to build the full solution.
That example essentially uses the default MAUI template, and modifies it slightly so that the actual 'click counter' value is set and retrieved from a native library on a per-platform basis. For Windows, that's a C++ DLL (works great). For Android, that's a .so library (works great). And for iOS, that's a static .a library, and here's where I'm running into trouble: when I try to launch this app using the iOS Simulator, it fails with a clang++ error, and something along the lines of "Could not extract the native library 'libCounteriOS.a' from .../obj/Debug/net6.0-ios/iossimulator-x64/linker-cache/libCounteriOS.a'. Please ensure the native library was properly embedded in the managed assembly (if the assembly was built using a binding project, the native library must be included in the project, and its Build Action must be 'ObjcBindingNativeLibrary')".
I created a C# .NET iOS Binding Library project (Counter.iOS in my example), and this is supposed to bundle libCounteriOS.a, which is generated when CounteriOS (a C++ project) is compiled. First, when Counter.iOS is built using Visual Studio on Windows, it fails to generate the Counter.resources folder in its 'bin' folder, along with the subsequent 'manifest' file. When I use Visual Studio for Mac, these files do get generated. So, I stuck with Visual Studio for Mac to build the iOS.Counter project (everything else is built with Visual Studio on Windows).
Regardless, I still get the "could not extract the native library" error I described. I've tried setting the library file's Build Action in Counter.iOS to ObjcBindingNativeLibrary, but that just results in an unhelpful "Build failed - see build log for details" error in Visual Studio for Mac, and I cannot find said log file for the life of me. On top of that, it's not an Objective C library anyway - it's a C++ one - so I'm not sure if this step is actually appropriate. Does it have to be Objective C? The Xamarin article suggests otherwise, and the native reference option 'Is C++' is there as well. I've also tried setting libCounteriOS.a's Build Action to 'BundleResource' - no luck with that either. I've tried it with .NET 7.0 as well - also no luck there.
I'm really at a loss. Is this even possible? It doesn't seem to work and I've been poking at it for weeks on it. That Xamarin article seems to suggest it should be possible. Any help would be greatly appreciated.

I am trying to integrate charts in my Remix application ,Can I really do that , if yes then how?

I used reat-chartjs-2 library and it throws an error
No "exports" main defined in ...path/node_modules/react-chartjs-2/package.json
I tried resolving those error but not able to find out how to integrate charts in server side rendering especially in Remix

How do I bundle in ImageMagick's dependencies in a Qt project?

I currently have a C++/QML application that uses ImageMagick to handle large images. I've written it only for Mac. It works fine when I run the program from Qt Creator, or even when I build it for Release and let it rely on weak linking.
I want to share this program with a friend who does not have the Qt libraries or ImageMagick installed. So I've run macdeployqt over the app bundle in a hope it would insert the frameworks required to run the program.
Thankfully that works. The program starts up and runs. However, once ImageMagick kicks in and tries to open a TIFF file, I'm presented with this error from an exception:
Error: Magick: no decode delegate for this image format 'TIFF'
After some various Google searches, I've only found issues from people who had that error from installing ImageMagick directly and are trying to use it from console. I can use ImageMagick and read TIFFs completely fine UNTIL I run the app after it has been deployed.
I'm guessing my question now is: How can I deploy the required "delegate" for tiff along with my app bundle?
Any help is appreciated! Thanks!

Error appears when building app that uses VTK in release mode

Good day everyone!
We're developing an app under Windows 7 (64 bit) using the Qt 4.8 framework and VTK. We're coding in C++ using QtCreator and the MingW-32 compiler.
In debug mode the compilation ends ok and we can launch and test the app. However, now that we want to build a release version, wild error messages appeared:
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
QWidget: Must construct a QApplication before a QPaintDevice
My partner has googled a bit and found that this is a rather common issue when trying to build a release version using VTK. The solution proposed is to add the path to the VTK debug library into the system path, before the release one. However, that didn't work for us. As of now, we're cluelessly trying to get the building done.
Do you have any idea what the solution might be?.
Thanks in advance!
Cheers!
EDIT: Here's the link with the supposed solution to this problem: supposed solution

C++ or Python (maybe else) to create GUI for console application in C

I have a Visual C console application (created in VC++2008EE) and I need to add GUI to it.
One idea was to invoke the console app as a subprocess and communicate with it using stdin and stdout. I tried to do that with Python subprocess module - but it deadlocks (probably because my console app is running continuously). As I understood from http://www.python.org/dev/peps/pep-3145/ it is not possible now to integrate continiously running console application with python subprocess module.
The other idea (more strait-forward probably) was to add a form to this console application project. But as I try to do it VS convers the project to one with "Common Language Runtime support" whatever it means, ads the form, a cpp file for form - and it's not compiling anymore saying:
Command line error D8016 : '/MTd' and '/clr' command-line options are incompatible
error BK1506 : cannot open file '.\Debug\Form_TEST.sbr': No such file or directory
No idea what it means. I have never dealed with C++, but I have used C and Python some time.
What would you recommend?
If you own the code for the console app, don't mess around trying to talk to it using input and output streams. Extract the logic of your console app into a library, and call that library from a GUI of your choice - either Windows.Forms from C#, Python GTK, ordinary GTK.
The reason that VS turns your application to CLR type is becuase it accidently thinks that you want to use winforms which are part of the .NET framework and the only way to use them is if your project is .NET as well.
You do have other options:
1. Add MFC GUI - native C++ GUI
2. better yet create a new .NET project (C#/VB.NET) with the desirect GUI and call your C/C++ dll using P-Invoke or COM interop