Boost logo

Boost :

Subject: Re: [boost] [filesystem][iostreams][program_options] linker issues on msvc
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2009-11-21 16:59:19


Alexander Arhipenko wrote:

Hi Alexander,

> Here is minimal example that reproduces the issue:
> #Jamfile.v2:
>
> exe foo : main.cpp /boost/filesystem ;
>
> //main.cpp:
>
> #include <boost/filesystem.hpp>
>
> int main(int argc, char* argv)
> {
> return 0;
> }
>
> In this case following error appears:
>
> main.obj : error LNK2019: unresolved external symbol
> "__declspec(dllimport) class boost::system::error_category const &
> __cdecl boost::system::get_system_category(void)"
> (__imp_?get_system_category_at_system@boost@@YAABVerror_category_at_12@XZ)
> referenced in function "void __cdecl boost::system::`dynamic
> initializer for 'system_category''(void)"
> (??__Esystem_category_at_system@boost@@YAXXZ)
>
>
> The reason is:
> #include <boost/filesystem.hpp> --> includes <boost/path.hpp> -->
> includes <boost/system/system_error.hpp> --> includes
> <boost/system/error_code.hpp>
>
> File boost/system/error_code.hpp has following declarations:
>
> BOOST_SYSTEM_DECL const error_category & get_system_category();
> BOOST_SYSTEM_DECL const error_category & get_generic_category();
>
> So, when the header above is included in main.cpp, BOOST_SYSTEM_DECL unrolls to:
> __declspec(dllimport).
> And this causes the linker error.
>
> As a result, library that links boost::filesystem should link boost::system.

Yes, and this:

    lib boost_filesystem
    :
    $(SOURCES).cpp
    ../../system/build//boost_system
    :

should be enough for that. I'll check why is that not working.

- Volodya


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