w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How does exporting templated C++ classes from shared library work on Linux?

Symbols related to instantiation of template are in no way different from other symbols.

On Linux, shared libraries all symbols not explicitly made private are exported, so a process will use only the one provided by the "first" library (you may have to pay a little more attention to your options if you want shared libraries use symbols provided by the main executable, but it is possible as well). You can make symbols explicitly private and have a shared library use the one it provides if you need; in the past you had to play with linker scripts for that, nowadays, gcc provides options and attribute to help fine grained control.

My understanding (but I'm not an expert on Windows, it is just what I read on forums like this one) is that on Windows the default is reversed and all symbols not explicitly made public are private but you can resolve the issue by changing attributes on symbols (I've no clue how easy or hard it is).

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.