Boost logo

Boost Users :

Subject: [Boost-users] boost filesystem library files can not be linked
From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2010-06-14 18:26:21


My ubuntu is 10.04. boost was installed from apt-get.

I compiled the following code. But the library is not available to
link. Would you please let me know how what link option I should use?

$ cat main.cpp
#include <boost/filesystem.hpp>
#include <iostream>
#include <string>

int main()
{
  boost::filesystem::path path1("/tmp/dir1/test1.c ");
  boost::filesystem::path path2("/tmp/dir1/.test1.profile");
  std::string result1 = boost::filesystem::basename (path1);
  std::string result2 = boost::filesystem::basename (path2);
  std::cout << result1 << std::endl;
  std::cout << result2 << std::endl;
  return 0;
}

$g++ -o main.exe main.cpp
/tmp/ccSvyGYq.o: In function
`__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x15d): undefined reference to
`boost::system::get_system_category()'
main.cpp:(.text+0x169): undefined reference to
`boost::system::get_generic_category()'
main.cpp:(.text+0x175): undefined reference to
`boost::system::get_generic_category()'
main.cpp:(.text+0x181): undefined reference to
`boost::system::get_generic_category()'
main.cpp:(.text+0x18d): undefined reference to
`boost::system::get_system_category()'
collect2: ld returned 1 exit status
make: *** [main.exe] Error 1

-- 
Regards,
Peng

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net