Boost logo

Boost Users :

Subject: Re: [Boost-users] [Exception] Duplicate symbol error when using errinfo_api_function in static library
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2013-10-02 17:48:06

On Tue, Oct 1, 2013 at 2:16 AM, Georg Leidinger <
georg.leidinger_at_[hidden]> 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.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at