Hi Emil,

I was able to figure out some more information about the issue and I could isolate it a little bit more. First it doesn't matter if it is a static or a shared library. Second it is not directly related to the Boost.Exception library but to the template class error_info which is used to create the predefined errinfo_xyz types. It is enough to instantiate the errinfo_api_function type in both doSomething() methods in the both implementation files. I am not so good in templates but I guess that the compiler creates the same symbol in both object files (ClassA.o and ClassB.o) for the type errinfo_api_function. I can see this via nm that I have the following line in both object files:

ClassA.o
0000000000059860 s __ZTIN5boost21errinfo_api_function_E

ClassB.o
0000000000059870 s __ZTIN5boost21errinfo_api_function_E 

Now, when the linker tries to link ClassA.o and ClassB.o to the main.o the both symbols clashes. But that would mean I could never use Boost.Exception or any other template instantiated type in a library.

Best Regards
Georg 

2013/10/2 Emil Dotchevski <emildotchevski@gmail.com>
On Tue, Oct 1, 2013 at 2:16 AM, Georg Leidinger <georg.leidinger@googlemail.com> wrote:
Dear readers,

I encountered a problem in my project when using Boost.Exception with the predefined types errinfo_xyz in a library project. I have two classes ClassA and ClassB in my library which both throw a boost::exception with errinfo_api_function type in their implementation file (.cpp) These both classes are compiled into a static library with the C/C++-Flags -fvisibility=hidden.
Then I have a main.cpp which creates an instance of ClassA and ClassB and links to the library which contains ClassA.o and ClassB.o. When I compile the main.cpp I get the linker error duplicate symbol for the errinfo_api_function object in ClassA.o and ClassB.o. If I remove the visibility=hidden flag, it links without problems. I am not an expert on the compiler flags, but I saw that many libraries use the visibility=hidden flag so I think it would be good, if my lib could also use it.   

Honestly I have no idea why this would happen. Anyone?

--
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users