开发者

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开发者_如何学Go_error::~runtime_error when I load the DKM. Any ideas? If I use std::runtime_error directly, I have no issues, but with Boost I seem to be having little success.

I would really like to use Boost, but it seems I am running into a lot of problems.


Remember that when you use DKMs, you are only doing partial linking on your translation units. This is why you can have unresolved symbols in your 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.

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.

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.

However, since your code doesn't explicitly instantiate or use the runtime_error class, it shows up as an unresolved symbol to the loader. 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".

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".

Two solutions are available:
a) do like you did and have an explicit use of the missing component.
b) Statically link the DKM in your base vxWorks image (which make it no longer dynamic or downloadable)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜