Boost logo

Boost :

Subject: [boost] [filesystem] 1.49 linking with c++0x
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2012-07-11 13:42:12


Given:

// cp.cpp
#include <boost/filesystem.hpp>
int main( int argc, char** argv ) {
  if( argc < 3 )
    return -1;
  boost::filesystem::copy_file( argv[1], argv[2] );
  return 0;
}

g++ -o cp cp.cpp -std=c++0x -I /usr/local/include
 /usr/local/lib/libboost_filesystem.a /usr/local/lib/libboost_system.a

Undefined symbols for architecture x86_64:
  "boost::filesystem3::detail::copy_file(boost::filesystem3::path const&,
boost::filesystem3::path const&, boost::filesystem3::copy_option,
boost::system::error_code*)", referenced from:
      boost::filesystem3::copy_file(boost::filesystem3::path const&,
boost::filesystem3::path const&) in ccUAyvBD.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

If I remove the -std=c++0x flag then it links just fine.

g++ --version
g++ (MacPorts gcc47 4.7.0_3) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Dan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk