简体   繁体   English

从初始化程序中止共享库的加载

[英]Abort the loading of a shared library from its initializer

I have a shared library that sets up shared memory in its initializer. 我有一个共享库,可在其初始化程序中设置共享内存。 When I can't allocate the shared memory, I would like to abort the loading of this library by the calling program, so that this program's load will fail and can act accordingly. 当我无法分配共享内存时,我想中止调用程序对该库的加载,以使该程序的加载失败并可以采取相应措施。

I am using QLibrary.isloaded() to check if the library is loaded in the calling program. 我正在使用QLibrary.isloaded()检查库是否已在调用程序中加载。

How can I prevent the library from being loaded when an error in the initializer occurs? 当初始化程序中发生错误时,如何防止加载库?

Since you mention Qt, perhaps using QPluginLoader is better. 既然您提到了Qt,也许使用QPluginLoader更好。 Read more about Qt Plugins and make your plugin return a pointer to a QObject, which would be NULL to indicate failure. 阅读有关Qt插件的更多信息,并使您的插件返回指向QObject的指针,该指针为NULL表示失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM