I wondered if someone could help me understand bjam a bit better. Below is a small project that does not work as is, but can be fixed by adding <link>static to the mylib line. Without it, a dll is produced for the library, and the executable fails to link.

Background: I am trying to write a bjam file for a new library. I would like it to build and run unit-tests on all possible configurations when --build-type=complete is specified, so cannot just hardwire static linking in.

Many thanks.


import boost ;
boost.use-project ;

using msvc : : "D:/Program Files/Microsoft Visual Studio 9.0/VC/bin/cl.exe" ;

# adding <link>static at the end of the next line makes the problem go away
lib mylib : testlib.cpp : <library>/boost//iostreams ;

exe testmain : testmain.cpp : <library>mylib <library>/boost//iostreams ;

----------------
testlib.cpp
----------------

#include <ostream>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>

namespace io = boost::iostreams;

void blah ()
{
    io::stream_buffer<io::file_sink> buf("log.txt");
    std::ostream                     out(&buf);
    out << "Hello";
}

--------------------
testmain.cpp
--------------------

extern void blah (void);

int main ()
{
  blah ();
}