Вопрос

If I open a library using dynamic loading in C++, can I later reload an updated version of that same library? I would test this myself, but I am curious about it's feasibility before I start looking into this as a potential solution to something I am working on.

In case it makes a difference, I am running on Linux. Being able to make it work on other operating systems would be nice, but is not a requirement.

Это было полезно?

Решение

Technically speaking you most certainly can — there is nothing that prevents you from doing so. This is how dlopen()/dlclose() work in user space. This is also how kernels load and unload dynamic modules, etc. In practice, though, a poorly written shared object or a host program may introduce disastrous side effects rendering the process (or the kernel, in case you are talking about a kernel module) unusable.

Другие советы

As already answered, this should work. About dlopen / dlclose clean usage in C++, you should have a look at this answer C++ Dynamic Shared Library on Linux.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top