コンパイル時にいくつかのコードがあります。次のエラーが出ます。それを解決する方法を知らない。私は-L/usr/lib/x86_64-linux-gnu
、-lboost_system
と-lboost_filesystem
を追加しようとしましたが、私はまだ同じエラーがあります。誰か助けてもらえれば、今この問題を解決する方法がわからないのですか?/usr/include/boost/filesystem/path.hpp:307: `boost :: filesystem :: path :: operatorへの未定義の参照
Agent.o: In function `boost::filesystem::path::append(char const*, std::codecvt<wchar_t, char, __mbstate_t> const&)':
/usr/include/boost/filesystem/path.hpp:307: undefined reference to `boost::filesystem::path::operator/=(char const*)'
Agent.o: In function `boost::filesystem::exists(boost::filesystem::path const&)':
/usr/include/boost/filesystem/operations.hpp:289: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
Agent.o: In function `boost::filesystem::create_directories(boost::filesystem::path const&)':
/usr/include/boost/filesystem/operations.hpp:399: undefined reference to `boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)'
Agent.o: In function `boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char [256]>::type>, boost::filesystem::path&>::type boost::filesystem::path::operator/=<char [256]>(char const (&) [256])':
/usr/include/boost/filesystem/path.hpp:302: undefined reference to `boost::filesystem::path::codecvt()'
collect2: error: ld returned 1 exit status
make: *** [player] Error 1
関連コードは
bool Agent::openTupleLog()
{
std::string dir="~/Experiments/Nov/";
// create the log directory & file path string
try
{
boost::filesystem::path kaway_log(dir
#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION == 2
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
, &boost::filesystem::native
# endif
#endif
);
if (! boost::filesystem::exists(kaway_log)
&& ! boost::filesystem::create_directories(kaway_log))
{
std::cerr << __FILE__ << ": " << __LINE__
<< ": can't create log directory '"
<< kaway_log.BOOST_FS_DIRECTORY_STRING() << "'" << std::endl;
return false;
}
kaway_log /= tuplesFilename;
M_kaway_log_name = kaway_log.BOOST_FS_FILE_STRING();
}
catch (std::exception & e)
{
std::cerr << __FILE__ << ": " << __LINE__
<< " Exception caught! " << e.what()
<< "\nCould not create log directory '"
<< dir
<< "'" << std::endl;
return false;
}
// open the output file stream
M_kaway_log.open(M_kaway_log_name.c_str());
if (! M_kaway_log.is_open())
{
std::cerr << __FILE__ << ": " << __LINE__
<< ": can't open log_file " << M_kaway_log_name
<< std::endl;
return false;
}
return true;
}