On 19.02.2014 17:57, Paulo Márcio Figueiredo Alves wrote:Paulo,I have made a simple test to show the problem (attached file). If you do not use Boost.Thread, the problem does not occur.
Adjust boost path (line 1) and call b2 -a, you'll see "recompile with -fPIC". Choose one of the commented choices
for target foo_static and you will see that there is no way to make it work, unless you call b2 -a cxxflags=-fPIC.
Is it a bug? Is there any workaround? Am I doing something wrong?
the issue here is that <cflags> is not passed through like this, we need to either make them passed, or issue
an error.
Anyway, the most immediate solution would be something like:
feature.feature fpic : off on : composite ;
feature.compose <fpic>on : <cflags>-fPIC <cxxflags>-fPIC ;
and use <fpic>on
Does this help?
- Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Thank you for the tips, /boost//headers is very useful and I was looking forward to something like that.The problem is my shared libraries are not used like:exe foo : foo.cc foo_shared : <threading>multi ;I use them with dlopen and LoadLibrary, and it drivers me to another chalenge, create the simplestbuild working on Windows, Linux and MacOS. On Windows I am not able to create a DLL with this:
lib foo_shared : foo_shared.cc foo_static : <link>shared : : <library>/boost//thread/<link>static ;
because gives me that:libfoo_static.lib(foo_static.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __thiscall boost::thread_exception::thread_exception(int,char const *)" (??0thread_exception@boost@@QAE@HPBD@Z)libfoo_static.lib(foo_static.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat@system@boost@@YAXXZ)libfoo_static.lib(foo_static.obj) : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::thread(void)" (??0thread@boost@@QAE@XZ) referenced in function "int __cdecl foo_static(void)" (?foo_static@@YAHXZ)libfoo_static.lib(foo_static.obj) : error LNK2019: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach@thread@boost@@QAEXXZ) referenced in function "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ)bin\msvc-12.0\debug\foo_shared.dll : fatal error LNK1120: 4 unresolved externalsso I have to use:lib foo_shared : foo_shared.cc foo_static : <link>shared <library>/boost//thread/<link>static : : <library>/boost//thread/<link>static ;or use <target-os>windows:<library>/boost//thread/<link>static and solve Windows and Linuxin an ugly way. I just don't know the best approach, and I think <cxxflags>-fPIC should beinherited regardless anything else. With this flags not being inherited, I have other problemslike using <cxxflags>-std=c++11 and Boost.Filesystem generates "undefined reference" under Linux.What you think? Is there any workaround, maybe force inheritance?Thank youOn Wed, Feb 19, 2014 at 7:59 PM, Thomas Suckow <thomas.suckow@pnnl.gov> wrote:
On 02/19/2014 11:33 AM, Paulo Márcio Figueiredo Alves wrote:It would appear that the override of <link>static is preventing boost-build from knowing it needs to use -fPIC.
I have made a simple test to show the problem (attached file). If you do
not use Boost.Thread, the problem does not occur.
Adjust boost path (line 1) and call b2 -a, you'll see "recompile with
-fPIC". Choose one of the commented choices
for target foo_static and you will see that there is no way to make it
work, unless you call b2 -a cxxflags=-fPIC.
Is it a bug? Is there any workaround? Am I doing something wrong?
That said, it bugs me thinking that the boost libraries are being linked into more than one of your shared libraries.
In your library, since random is header-only, I would use:
: <use>/boost//headers <implicit-dependency>/boost//headers ;
AFAIK, this is the most correct syntax. I've been trying to figure out the best syntax since modular-boost changes some things.
This is the best I could come up with:
lib foo_static : foo_static.cc : <link>static <cxxflags>-fPIC <use>/boost//headers <implicit-dependency>/boost//headers ;
lib foo_shared : foo_shared.cc foo_static : <link>shared : : <library>/boost//thread/<link>static ;
exe foo : foo.cc foo_shared : <threading>multi ;
I am kind of disappointed in this solution :-/
-
Thomas
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build