I have been trying to figure this out for a few days and can't seem to find a solution. I am creating a Windows Forms application inside of MSVS 2012 (but the application itself is using MSVS 2010 binaries and .NET 4.0). The application requires the use of CLI/CLR managed code.
I have followed the Getting Started guide and built the libraries using:
bootstrap.bat
.\b2.exe --toolset=msvc-10.0 --build-type=complete
I setup/linked the directories to my project inside of Visual Studio:
Here is all that I added to my previously compiling and executing code:
#define BOOST_LIB_DIAGNOSTIC //show diagnostics
#define BOOST_USE_WINDOWS_H
#define BOOST_FILESYSTEM_NO_DEPRECATED //don't use deprecated code
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
Here is the output of the build (Release/Win32):
1>------ Build started: Project: PROJECT_NAME (Visual Studio 2010), Configuration: Release Win32 ------
1> PROJECT_NAME.cpp
1> Linking to lib file: libboost_filesystem-vc100-mt-1_53.lib
1> Linking to lib file: libboost_system-vc100-mt-1_53.lib
1>PROEJCT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::system_category(void)" (?system_category@system@boost@@$$FYMABVerror_category@12@XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" (?generic_category@system@boost@@$$FYMABVerror_category@12@XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "void __clrcall boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@$$FYMXPB_W0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$codecvt@_WDH@5@@Z)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __clrcall boost::filesystem::path::codecvt(void)" (?codecvt@path@filesystem@boost@@$$FSMABV?$codecvt@_WDH@std@@XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __clrcall boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close@detail@filesystem@boost@@$$FYM?AVerror_code@system@3@AAPAX@Z)
1>C:\Users\USERNAME\Documents\Visual Studio 2012\Projects\PROJECT_NAME\Release\PROJECT_NAME.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Do I still not have something built/linked correctly? Let me know if there's more information needed and I will supply what I can.
Reviving an old post, I know, but I spent a long time trying to figure out a similar issue, so I'm posting for the next person who comes across similar issues.
For this to work, you'll need to build Boost with VS2012 or download it from Teeks99 or Sourceforge. I was unable to make it work with VS2010.
Change the Platform Toolset to Visual Studio 2012 (v110) in the Project configuration properties. That worked for me when I was trying to figure out a similar problem (#include <boost/filesystem.hpp>
in a VS2010 minimal example code). Make sure that the Common Language Runtime Support is set to /clr
(NOT /clr:pure
).