Hi Alex,


I still got some of warning C4273: inconsistent dll linkage like the following


----------------------

1>  thread.cpp

1>..\Boost\thread.cpp(186): warning C4273: 'boost::thread::thread' : inconsistent dll linkage

1>          C:\3rdParty\BOOST_LIBRARY\boost-1.47.0\boost/thread/detail/thread.hpp(154) : see previous definition of '{ctor}'

1>..\Boost\thread.cpp(189): warning C4273: 'boost::thread::start_thread' : inconsistent dll linkage

1>          C:\3rdParty\BOOST_LIBRARY\boost-1.47.0\boost/thread/detail/thread.hpp(120) : see previous definition of 'start_thread'

1>..\Boost\thread.cpp(200): warning C4273: 'boost::thread::thread' : inconsistent dll linkage

1>          C:\3rdParty\BOOST_LIBRARY\boost-1.47.0\boost/thread/detail/thread.hpp(122) : see previous definition of '{ctor}'

1>..\Boost\thread.cpp(242): warning C4273: 'boost::thread::~thread' : inconsistent dll linkage

1>          C:\3rdParty\BOOST_LIBRARY\boost-1.47.0\boost/thread/detail/thread.hpp(155) : see previous definition of '{dtor}'


--------------


BTW, *after* I built boost thread libraries, I set #define BOOST_THREAD_DYN_LINK in boost-1.47.0/boost/boost/config/user.hpp, should I set  BOOST_THREAD_DYN_LINK in this file *BEFORE* building boost thread libraries? Is it correct? Did I do something wrong?



Thank you for your great help!

Yan

--- On Fri, 11/18/11, code <b4code@yahoo.com> wrote:

From: code <b4code@yahoo.com>
Subject: RE: [Boost-users] some warning C4273: inconsistent dll linkage
To: "Alex Perry" <Alex.Perry@smartlogic.com>
Date: Friday, November 18, 2011, 1:12 PM

Thank you so much, Alex !! I understand better.

Yan

--- On Fri, 11/18/11, Alex Perry <Alex.Perry@smartlogic.com> wrote:

From: Alex Perry <Alex.Perry@smartlogic.com>
Subject: RE: [Boost-users] some warning C4273: inconsistent dll linkage
To: "code" <b4code@yahoo.com>
Date: Friday, November 18, 2011, 9:43 AM

Hi Yan,

 

Probably not : - )

 

It actually depends on your toolset / platform that you are using.

 

#define BOOST_THREAD_NO_LIB like its version for all the boost libraries #BOOST_ALL_NO_LIB switches of the automagical linking of libraries for boost.

 

Personally on platforms that support this (msvc, borland etc) I find it really useful – give your project the libdir of the boost libs and let the headers figure out what the name of the lib it wants to link to is (in fact I liked it so much I ended up nicking the boost naming conventions and using them for all our internal company library code coz it just made life so much easier – no more worrying whether dependent lib was compiled with /MD, /MDd or /MT etc which is such a pain with windows based compilers – especially when using dll’s rather than static libs)

 

The NO_LIB define is there to avoid this automatic naming (ie the #pragma comment(lib,) the header adds to your code if supported by your toolset)  and so it  lets you name the lib you want to link to manually in your makefile / solution as per non boost libs (or when using gcc  … ). For example in some x-platform code if you wanted the makefile the same for linux/windows (using cygwin or some such).

 

Alex

 

 

 

From: code [mailto:b4code@yahoo.com]
Sent: 18 November 2011 16:07
To: boost-users@lists.boost.org; Alex Perry
Cc: b4code@yahoo.com
Subject: Re: [Boost-users] some warning C4273: inconsistent dll linkage

 

Hi Alex,

Thank you so much for the great advice.

When I set #define BOOST_THREAD_DYN_LINK in my code, do I need to set
#define BOOST_THREAD_NO_LIB at the same time?

Thank you so much again!

Yan

--- On Fri, 11/18/11, Alex Perry <Alex.Perry@smartlogic.com> wrote:


From: Alex Perry <Alex.Perry@smartlogic.com>
Subject: [Boost-users] some warning C4273: inconsistent dll linkage
To: "boost-users@lists.boost.org" <boost-users@lists.boost.org>
Cc: "b4code@yahoo.com" <b4code@yahoo.com>
Date: Friday, November 18, 2011, 1:11 AM


On Thu, 17 Nov 2011 12:07:57 -0800 (PST) code <b4code@yahoo.com> wrote:-
> Hi Boost Users,
>
> When I compiled and linked my projects with Boost libraries, I got the
> following warnings
>

...snip...

> I want to link Boost.thread dll dynamically and other Boost libraries statically.
>
> If I set #define BOOST_ALL_DYN_LINK, I could not generate

...snip...

I didn't see any answer to this but apologies if its already been answered.

#define BOOST_ALL_DYN_LINK

Is for use within your own consuming code - use the bjam --link option to control which version of boost libraries are built eg in boost root do:-

bjam variant=debug,release threading=multi link=shared stage --with-thread

which would build boost-thread as dll (bjam --help to get more info on options) then:

#define BOOST_THREAD_DYN_LINK

In your code would use the dll version of boost.thread (any other boost libs would still be looking for static versions)

HTH

Alex