简体   繁体   English

在运行时加载的C ++动态链接库-Poco / qmake

[英]C++ Dynamically Linked Libraries loaded at runtime - Poco / qmake

I am having trouble with Boost and my Mac OS X. 我在Boost和Mac OS X上遇到问题。

I am using Qt Creator as a development platform for C++ projects, primarily because of the IDE and qmake . 我将Qt Creator用作C ++项目的开发平台,主要是因为IDE和qmake

Right now I am working on a C++ app that is supposed to be cross-platform but I do not want to use the Qt framework itself. 现在,我正在开发一个应该跨平台的C ++应用程序,但是我不想使用Qt框架本身。 Instead I am using the STD libraries (C++11) , Poco and Boost . 相反,我使用的是STD(C ++ 11)PocoBoost

One of the things I am trying to achieve is a plugin system that loads dynamically linked libraries at runtime. 我要实现的目标之一是在运行时加载动态链接库的插件系统。

I saw a few projects like Boost-extension which is no longer supported and several others. 我看到了一些不再受支持的项目,如Boost-extension ,还有其他一些项目。

Right now I am using Poco's Shared Libraries and their Class Loader . 现在,我正在使用Poco的共享库及其Class Loader I am following closely the tutorial at the end of the presentation. 我将在演讲结束时密切关注本教程。 Unfortunately I cannot get it working and I am receiving the following error upon compilation, where the ServiceBase class is my plugin interface. 不幸的是,我无法使其正常运行,并且在编译时收到以下错误,其中ServiceBase类是我的插件接口。

Undefined symbols for architecture x86_64:
"Poco::SharedLibrary::getSymbol(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SharedLibrary::hasSymbol(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SharedLibrary::SharedLibrary(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SystemException::SystemException(std::string const&, int)", referenced from:
      Poco::MutexImpl::unlockImpl() in main.o
      Poco::MutexImpl::lockImpl() in main.o
  "Poco::LibraryLoadException::LibraryLoadException(std::string const&, std::string const&, int)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
ld: symbol(s) not found for architecture x86_64

I have the Poco libraries linked and pretty much everything seems to be implemented. 我链接了Poco库,并且几乎所有内容似乎都已实现。

Any advice on how to fix that? 关于如何解决该问题的任何建议?

PS I am also looking for alternatives on implementing the plugin system, probably more-powerful and certainly cross-platform. PS我也在寻找实现插件系统的替代方法,可能更强大,而且肯定是跨平台的。

Disclaimer. 免责声明。 I have no experience with this Poco library. 我没有使用此Poco库的经验。

Without further details on your environment or your tools... I can only provide some very general advice: 没有您的环境或工具的更多详细信息...我只能提供一些非常一般的建议:

How I'd chase this is: 我怎么追求的是:

  1. Locate in what library or object file are defined the symbols reported as undefined symbols . 在报告为未定义符号的符号中找到定义的库或目标文件。 On unix-like environments this can be achieved with the nm tool 在类似Unix的环境中,可以使用nm工具来实现
  2. Verify that the libraries or objects are compiled on the right architecture (I see you're using x86_64) file tool might help you there 验证库或对象是在正确的体系结构上编译的(我看到您正在使用x86_64) 文件工具可能会帮助您
  3. Verify that you're referring to the library in the linker command line (look for a -l for dynamic or static libraries) or that you're including the object file or the static library in the list of things to link. 验证您是在链接器命令行中引用该库(对于动态库还是静态库,请查找-l),或者在要链接的事物列表中包括目标文件或静态库。
  4. Verify that you're referring to the right library (either through -L flags or the LD_LIBRARY_PATH env variable (or LD_LIBRARY_PATH_64 in some systems eg Solaris for 64bits build) 验证您引用的是正确的库(通过-L标志或LD_LIBRARY_PATH env变量(或在某些系统中,例如LD_LIBRARY_PATH_64,例如用于64位的Solaris)

I know you said you have linked the Poco libraries, but the error is clearly that a symbol is missing. 我知道您说您已经链接了Poco库,但是错误显然是缺少一个符号。 Either the library is missing or you need to fiddle with the order of the -l flags to satisfy the dependencies. 库丢失了,或者您需要弄乱-l标志的顺序来满足依赖性。 The nm might help you there in determining what objects or libraries refer to the symbol (must come first) and what objects or libraries define the symbol (must come later). nm可能会帮助您确定哪些对象或库引用了该符号(必须在最前面)以及哪些对象或库定义了该符号(必须在后面)。

Sorry not being of more help. 抱歉,没有更多帮助。

PS In addition you might want to look at Linking error with Poco Net which might be related. PS此外,您可能想查看可能与Poco Net相关的链接错误

One more reference to a question that details different causes for linker errors: What is an undefined reference/unresolved external symbol error and how do I fix it? 关于此问题的另一个参考,详细说明了链接器错误的各种原因: 什么是未定义的参考/未解决的外部符号错误,如何解决?

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

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