Boost logo

Boost :

Subject: Re: [boost] Checking library binary compatibility with respect to compile time options
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-04 18:57:05

joel falcou wrote:
> I was pondering how to event or at least warn users when they use a .a
> compiled with a set of define with an
> application compiled with divergent options (like having different -D
> that may cause ODR violation).
> On IRC, I was linked to this page for MSVC 10:
> That defiens some pragma that exactly do that.
> However, it's MSVC 10 specific.
> After a few brainstorming, we ended up with a simple solution to
> emulate this.
> The code source is here:
> Here is a use case:
> g++ -c foo.cpp -o foo.o -I/usr/local/include/boost-1_43 -DGOOD_LIB
> g++ -c main.cpp -o bmain.o -I/usr/local/include/boost-1_43 -DBAD_LIB
> -I./ g++ -c main.cpp -o gmain.o -I/usr/local/include/boost-1_43 -DGOOD_LIB
> -I./
> Here, we compiel foo with some settings and try to link it with two
> different setup for main.o
> The gcc output, showing the divergence in option is detected:
> g++ bmain.o foo.o -o bmain
> bmain.o: In function `__static_initialization_and_destruction_0(int,
> int)': main.cpp:(.text+0x2a): undefined reference to
> `boost::config::test_library_version_mismatch_with_version_being_2()'
> collect2: ld returned 1 exit status
> Of course, when you link the good pair of .o :
> g++ gmain.o foo.o -o gmain
> Nothing happens
> I guess some details need to be hammered out like visibility and such
> but could this be a valuable addition to boost (liek boost config for
> example)
> or have I overengineered something useless ?

I think this might be related to an idea I posted last may:

I'm not sure if this is the same or different

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at