Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem linking boost filesystem 1_36_0 on ubuntu gcc 4.2
From: Kevin Stevens (kstevens_at_[hidden])
Date: 2008-10-31 17:42:24


Answering my own question. Hopefully someone can google this error in the future and fix it a lot quicker than the several hours it took me....

The problem was that I was not correctly specifying the include headers. I had entered -I/path/to/boost_1_36_0/boost not -I/path/to/boost_1_36_0. I thought I had that path right because everything was compiling. What I did not take into account was that boost 1_34_1 was installed via the package manager by the administrator of the system so the include files were automatically being picked up despite me not explicitly specifying them. The interfaces I was using did not change, but the underlying code did, hence my code still compiled, but refused to link and unfortunately spit out misleading errors.

-K

From: Kevin Stevens
Sent: Thursday, October 30, 2008 5:15 PM
To: 'boost-users_at_[hidden]'
Subject: Problem linking boost filesystem 1_36_0 on ubuntu gcc 4.2

Hello, when I am trying to link boost::filesystem into my program I am receiving link errors. I am trying to convert from boost 1_34_1 to 1_36_0- previously this built against 1_34_1 without any issue.

When I link I get the following error:
/home/kstevens/code/CrossingEngine/../lib/libtypes.a(Config_Constants.o): In function `boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, bool>::type boost::filesystem::exists<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)':
/usr/include/boost/filesystem/operations.hpp:279: undefined reference to `boost::filesystem::detail::status_api(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int&)'

I did an objdump -CT on libboost_filesystem-gcc42-mt-1_36.so and got the following two functions as output but not the one the linker appears to be looking for:
000000000000c4e0 g DF .text 00000000000000e3 Base boost::filesystem::detail::status_api(std::string const&, boost::system::error_code&)
000000000000c720 g DF .text 00000000000000e3 Base boost::filesystem::detail::symlink_status_api(std::string const&, boost::system::error_code&)

Could this be a bad build? Am I missing something- perhaps I need to link another file in? I built 1_36_0 myself using a default configuration other than telling it where to put the output libs. I have ensured that I am linking against and including headers from 1_36_0, and have also made a clean build. Is there anything else I should try?

Thank you,
-Kevin

This is my code snippet that uses boost::filesystem:

//Create Directory if it does not already exist.
      if(!boost::filesystem::exists(reportFilePath))
      {
            cout << "output path: " << reportFilePath << " did not exist, which may indicate a different configuration than was intended, creating directory now." << endl;
            try
            {
                  boost::filesystem::path path(reportFilePath);
                  boost::filesystem::create_directory(path);
            }
            catch(boost::filesystem::filesystem_error e)
            {
                  cout << "Error: " << e.what() << endl;
            }

      }



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