Sunday, February 15, 2015

undefined reference of copy_file

./source/main.o: In function `boost::filesystem::copy_file(boost::filesystem::path const&, boost::filesystem::path const&)':
/home/kokhoe/tool/boost_1_54_0/boost/filesystem/operations.hpp:384: undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option, boost::system::error_code*)'
collect2: error: ld returned 1 exit status
make: *** [syncFile] Error 1
I got this error when I have the following piece executed:
path source = file_A;
path dest = path_B;
copy_file(source, dest);
Luckily, there is already a programmer had the problem solved (read here), what he did is to put this code before #include <boost/filesystem.hpp>.

#define BOOST_NO_CXX11_SCOPED_ENUMS

Do take note also path_B must be a file name rather than a path name.

No comments: