简体   繁体   English

在VxWorks中使用Boost C ++库时出错

[英]Error using Boost C++ Libraries with VxWorks

I am attempting to use the boost header-only Property Tree library with VxWorks 6.6 in kernel mode, and I am getting an undefined symbol for std::runtime_error::~runtime_error when I load the DKM. 我试图在内核模式下将仅Boost标头的属性树库与VxWorks 6.6一起使用,并且在加载DKM时出现std::runtime_error::~runtime_error的未定义符号。 Any ideas? 有任何想法吗? If I use std::runtime_error directly, I have no issues, but with Boost I seem to be having little success. 如果直接使用std::runtime_error ,我没有问题,但是使用Boost似乎没有什么成功。

I would really like to use Boost, but it seems I am running into a lot of problems. 我真的很想使用Boost,但是似乎遇到了很多问题。

Remember that when you use DKMs, you are only doing partial linking on your translation units. 请记住,当您使用DKM时,只对翻译单元进行了部分链接。 This is why you can have unresolved symbols in your DKM. 这就是为什么您的DKM中可以包含未解析的符号的原因。

For example, if you use printf, when the DKM is partially linked, it doesn't know what the address of the printf function is, as it might change between different vxWorks images. 例如,如果使用printf,则在部分链接DKM时,它不知道printf函数的地址是什么,因为它可能在不同的vxWorks映像之间改变。

When you load a DKM, the vxworks dynamic loader will look at the DKM and find all the unresolved symbols in the DKM and match them against the symbols in the kernel. 加载DKM时,vxworks动态加载器将查看DKM并查找DKM中所有未解析的符号,并将它们与内核中的符号进行匹配。

I suspect that what you are running into is that your code is probably template based which doesn't get instantiated until load time and part of the template has a reference to the runtime_error class. 我怀疑您遇到的是您的代码可能是基于模板的,直到加载时间才会实例化,并且模板的一部分引用了runtime_error类。

However, since your code doesn't explicitly instantiate or use the runtime_error class, it shows up as an unresolved symbol to the loader. 但是,由于您的代码没有显式实例化或使用runtime_error类,因此它对于加载程序而言显示为未解析的符号。 Templates can be a bear to deal with in a dynamic loading situation. 在动态加载情况下,模板可能是一个负担。

The linker thinks: "No problem, the dynamic loader will take care of that". 链接器认为:“没问题,动态加载程序将解决此问题”。 Unfortunately, the loader sees this unresolved symbol and loudly says "Hey...I know nothing about runtime_error". 不幸的是,加载程序看到了这个未解决的符号,并大声说“嘿...我对runtime_error一无所知”。

This is why the documentation states (paraphrasing): "For C++, your DKM must be self-contained (as in implements all the classes required & used) and not rely on other DKMs". 这就是文档说明(措辞)的原因:“对于C ++,您的DKM必须是独立的(如在实现所需和使用的所有类中一样),并且不能依赖于其他DKM”。

Two solutions are available: 有两种解决方案:
a) do like you did and have an explicit use of the missing component. a)像您一样做,并明确使用缺少的组件。
b) Statically link the DKM in your base vxWorks image (which make it no longer dynamic or downloadable) b)在基本vxWorks映像中静态链接DKM(这使其不再动态或不可下载)

If you were to use RTPs (instead of DKMs), you wouldn't have this particular problem, as the RTP is fully linked, not partially linked. 如果要使用RTP(而不是DKM),则不会出现此特定问题,因为RTP是完全链接的,而不是部分链接的。

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

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