StaticLinkBoostThreads
From: David Barrett
To: boost@lists.boost.com
Subject: Successfully compiled & static linked with Boost.Threads using Visual Studio .NET 2003
Date: Sun 8/22/2004 2:13 PM

Hi, I see a lot of people have been having problems statically-linking Boost.Threads with Visual Studio .NET 2003. For what it's worth, I just got it to work, and here's what I did:

1) Created and entered a C:\Libraries folder

 
C:\> Mkdir c:\Libraries
 
C:\> cd c:\Libraries

2) Checked out the latest code from CVS using:

 
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/boost login
[Hit when it asks for a password]
 
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/boost checkout boost
 
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/boost logout

3) Installed Boost.Build and Boost.Jam

4) Built everything:

 
C:\Libraries\Boost> bjam --prefix=c:\Libraries\Boost install

5) Launched Visual Studio .NET 2003

6) Created a new Win32 Console Project (CTRL+SHIFT+N) and accompanying solution named BoostTest

7) Configured the wizard to create an Empty Project (click "Application Settings", check "Empty Project", click "Finish")

8) Configured the project to use the "Multi-threaded Debug Runtime Library" (Project::BootTest Properties, C/C++::Code Generation::Runtime Library)

9) Configured the project to search for the Boost include files (Project::BootTest Properties, C/C++::General::Additional Include Directories) by adding:

 
C:\Libraries\boost\include

10) Created a new file named BoostTest.cpp (CTRL+SHIFT+A, click "C++ File", type "BoostTest.cpp" in the Name field, click Open)

11) Inserted the single include line:

     
#include <boost/thread/thread.hpp>

12) Compiled (CTRL+F7)

13) It works!

So yes, that all seems pretty obvious. But it took me a long time to get working. I was unable to get anything with a Boost.Thread header to compile at all (with any combination of static/dynamic runtimes, #defines, and code hacks) using the 1.31.0 release currently available for download via SourceForge. But it works now, and I'm proof that it can be done. Good luck!

-david


Login
Powered by QwikiWiki v1.4 - www.qwikiwiki.com