boost filesystem library files can not be linked

Peng Yu pengyu.ut at
Mon Jun 14 23:30:12 UTC 2010

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

I compiled the following code. But the library is not available to
link. I don't find where the library files are. Do I need to install
some other package in order to get the libraries?

$ 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 -lboost_filesystem -lboost_system
/usr/bin/ld: cannot find -lboost_filesystem
collect2: ld returned 1 exit status


More information about the ubuntu-users mailing list