Boost logo

Boost :

Subject: [boost] [config] gcc,msvc,mingw visibility
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-04-23 01:19:03


I've been enabling limited gcc visibility so that it works similarly to msvc
*_DECL attributes and will export from the DLL/DSO only those symbols which
need to be exported.

I've had a lot of difficulty with this.

I followed the instructions

http://www.boost.org/doc/libs/1_58_0/libs/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code.macros_controlling_shared_library_symbol_visibility

which more or less boil down to using BOOST_SYMBOL_EXPORT when functions are
exported, BOOST_SYMBOL_IMPORT when functions are imported, and
BOOST_SYMBOL_VISIBLE on class declarations.

I set my Jamfile.v2 in the library build to enable gcc visibility=hidden and
let her rip.

After the more or less normal back and forth it seemed that the library
built and work on all platforms/compilers. .... EXCEPT Mingw. Hmmmm -
this shouldn't be too tough, just look at how the other libraries did it.
Turns out that it seems that no boost libraries actually enable gcc
visibility in their builds - at least as far as I can tell. (I didn't dig
into the depths of jam tools files). After a fair amount of research I
concluded that for windows platforms - regardless of whether they are built
with minnow (gcc) or mdvc, one needs to define BOOST_SYMBOL_VISIBLE as
BOOST_SYMBOL_IMPORT or BOOST_SYMBOL_IMPORT which of course makes things more
complicated.

So here is what I came up with.

My questions are:

a) did I do this right?
b) is there a simpler way
c) if the answer to the above is no - can the documentation be updated?

Robert Ramey

--
View this message in context: http://boost.2283326.n4.nabble.com/config-gcc-msvc-mingw-visibility-tp4674714.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk