I am writing C++ addons for an Electron.JS application which calls macOS native APIs. Some of the API calls are introduced in the newer versions of macOS: (say an API call that is introduced in macOS 12).
But I want my application to work for the older versions of macOS so I wrapped the code that uses the API in an if block such if (#available(macOS 12, *)) { ...}.
In the electron app, when node js loads the addon, it crashes on the older versions of macOS telling that the API symbol is missing:
Termination Reason: DYLD, [0x4] Symbol missing
Dyld Error Message:
Symbol not found: ---API method---
Referenced from: /var/folders/*/.com.mobeus.mobeglass.LMWnli
Expected in: flat namespace
Although I do not call the method but it crashes on dlopen when in Javascript I call const addon = require('addon')
I know that there are lazy and immediate ways of resolving symbols for the shared library but I am not sure how to set it from the Electron (or NodeJS) application and whether it will solve my problem.
Related
I am trying to use the Tensorflow C api in an xcode project. As soon as the app starts running a BAD_INSTRUCTION error is generated on the main thread. This error comes from:
tensorflow::monitoring::MetricDef<(tensorflow::monitoring::MetricKind)1, long long, 2>::MetricDef<char [11], char [7]>(absl::lts_2020_02_25::string_view, absl::lts_2020_02_25::string_view, char const (&) [11], char const (&) [7]) ()
I installed the api using: https://www.tensorflow.org/install/lang_c
I am building for x86_64 architectures (Using Rosetta to translate) and linked the library through specifying a runpath search path to the .dylib's directory. I also included this path as a regular search path and added the header search path too. Finally, I added both .dylibs to the 'link binary with libraries' list.
I am running xcode 12.4 on a M1 macbook pro. If anyone knows any way to get more information about the crash out of xcode that'd be useful too.
I have tried installing on an intel MacBook and that worked fine.
The M1 processor is ARM.
You compiled for x86_64 (Intel architecture) this means, that it isn't compatible.
You'd have to compile it for ARM, otherwise it won't run. (That's like trying to run JVM Bytecode in .NET, it just won't work)
For more information, see this answer
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>'".
I'm building an application to which I've just added a library (which in turn uses a number of other libraries), and for some reason it's trying to use "GetLogicalProcessorInfo" from kernel32.dll. Unfortunately, this function is newer than the Windows version that some of my users are using (some are using XP SP2, this function requires XP SP3) - so I got error reports about this.
I'm trying to figure out why this function is being referenecd, but I can't find it. I don't see it in any of the .lib files that I'm using. Or in any .cpp or .h file. Still, something is triggering that this function is used.
So, is there a way to find out where this is coming from? Which function or which library is using it?
I'm developing in Visual Studio 2015 with the Intel C++ compiler. There is a way to tell it to compile for Windows XP, but the minimum supported version is SP3 - before I added this library my code worked fine though. If I have to push people to move to SP3, so be it, but I would prefer not to. Many are using a pc running my software as an appliance, often not even connected to the internet, and have been running it for years (hence the old OS).
If you have immunity debugger or ollydbg, you can open up your program in that. Once its loaded right click and select view which shows all the modules your program imports. Select your library and right click again and click on search->all intermodular calls and you'll see a list of functions that the module calls from external libraries. If you double click on the specific function it will take you to the location in that program which calls that kernel32 function.
Most likely you probably won't be able to get rid of it as it will be used by other parts of the library which you don't control.
A webapp using native code works fine in Glassfish 2.x.
In 3.1.1, it fails with:
[#|2012-04-18T14:43:08.330+0000|SEVERE|glassfish3.1.2|com.sun.jersey.spi.container.ContainerResponse|_ThreadID=21;_ThreadName=Thread-2;|The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.UnsatisfiedLinkError: com.basistech.rnt.jni.initializeEnvironmentSpecificRootDirectory(Ljava/lang/String;)Z
at com.basistech.rnt.jni.initializeEnvironmentSpecificRootDirectory(Native Method)
Note that this is the version of the linkage error that complains about a particular symbol, not about the entire library.
The very same JNI lib works fine run from a sample Java program outside of Glassfish on the very same machine.
Reading the JDK source, this would seem to be possible only if dlsym (we're on Linux) fails to return the symbol. (This is all Java 1.6.x.) I'm stumped as to what Glassfish could possibly be doing that would cause dlsym to fail to see this symbol in the shared lib.
Any ideas out there?
I have a simple C++ (non Qt Quick) application (that does not use .pro mechanism) built against the official Qt 5.4.2 x64 build (with openGL support).
As soon as I use the QWebEngineView object in my application, it fails to load with a message "Specified procedure could not be found".
With the help of gflags, it seems it fails to find the following demangled procedure:
public: __cdecl QOpenGLWidget::QOpenGLWidget(class QWidget * __ptr64,class QFlags<enum Qt::WindowType>) __ptr64
I am not sure to understand why this cannot be found, I have put for the sake of testing all the dlls in Qt_DIR\bin next to the application, and all the plug-ins.
The preprocessor list I use to build my app are as follow:
WIN32;_DEBUG;_WINDOWS;_USRDLL;WIN64;QT_WEBENGINEWIDGETS_LIB;QT_WEBENGINE_LIB;QT_QUICK_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_UITOOLS_LIB;QT_CORE_LIB;WIN32PROJECT5_EXPORTS;PLUGIN_VENDOR_NAME="$(VendorName)";PLUGIN_VERSION="$(PluginVersion)";PLUGIN_NAME="$(PluginName)";%(PreprocessorDefinitions)
And the input libraries:
Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5WebKitd.lib;Qt5WebKitWidgetsd.lib;Qt5WebEngineWidgetsd.lib;Qt5WebEngined.lib;Qt5OpenGLExtensionsd.lib;Qt5OpenGLd.lib;Qt5Networkd.lib;Qt5Xmld.lib;D:\NotBackedUp\Tools\Qt\5.4\msvc2013_64_opengl\lib\qtmaind.lib;shell32.lib;Qt5Quickd.lib;Qt5PrintSupportd.lib;Qt5Qmld.lib;Qt5UiToolsd.lib;glu32.lib;opengl32.lib;gdi32.lib;user32.lib;o2d.lib;%(AdditionalDependencies)
I wanted to try a simple example in Qt Creator 3.6.1 but it complains: Project ERROR: Unknown module(s) in QT: webenginewidgets
The browser.exe example runs fine (built with visual studio)
Do you have any idea of what is wrong?
PS: I am on windows 8.1.
For the procedure not found, my dll is a plug-in of a Qt application that is not built with opengl support. Only my dll is built with opengl support.
When initializing the plug-in, the application uses its own dlls rather the mine... and therefore fails to have any opengl support for the web engine.
For Qt Creator, it selected automatically a wrong kit. I had to create a new kit which maps to the correct Qt binaries (with opengl support): follow this: http://doc.qt.io/qtcreator/creator-configuring-projects.html.
Hope it will help someone