0

I am trying to build an executable for a project that uses boost, on my machine (Ubuntu 12.04 LTS) and on node (CentOS) on a cluster system. I managed to install boost from source on both the machines. When I run the make command, I am able to get an executable for my project on my machine but not on the node. On the cluster node, it says:

source/MainCompressor.cpp: In member function ‘void MainCompressor::compress(std::__cxx11::string, std::__cxx11::string)’:
source/MainCompressor.cpp:76:80: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         boost::filesystem::copy_file(reference, outpath + reference.filename().string());
                                                                                ^
source/MainCompressor.cpp:93:49: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
     compList << outpath << reference.filename().string() << endl;
                                                 ^
source/MainCompressor.cpp:99:47: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         string filename = filepath.filename().string();
                                               ^
source/MainCompressor.cpp: In member function ‘void MainCompressor::decompress(std::__cxx11::string, std::__cxx11::string)’:
source/MainCompressor.cpp:171:47: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         string filename = filepath.filename().string();

I installed the same version(s) of boost (1.55 and 1.59) on both the machines. I am not sure why I am not getting the error on my machine but getting an error on the node. Any help will be appreciated in this regard.

Edit 1: The following is my path variable setting:

PATH=/home/head/cmp/soft/sft/boost_1_59_0:/home/head/cmp/soft/sft/boost_1_55_0/bin:/home/head/cmp/soft/sft/gcc/bin:$PATH
Python_user
  • 1,378
  • 3
  • 12
  • 25

1 Answers1

0

To me it looks like on the node there's an older version of boost installed. Older versions of boost::filesystem::path didn't have a string member function. Check the include path, the compiler gets the wrong headers from somewhere. You may add some additional arguments to gcc command line to see which include files are actually used. See: /show include equivalent option in g++

Community
  • 1
  • 1
Joerg S
  • 4,730
  • 3
  • 24
  • 43
  • The node previously didnt have any version of boost installed... I am sure of it... And I personally installed the two boost versions... Btw, how do I find out which boost version is being used (or installed)?? – Python_user Nov 16 '15 at 18:20
  • Moreover, I am using the -MMD version to g++... ALso, i have installed gcc (g++) locally and have included in my path variable... – Python_user Nov 16 '15 at 18:24
  • I'm 99% sure that there's some wrong header somewhere included. Try listing all the includes the compiler uses: http://stackoverflow.com/questions/4479049/show-include-equivalent-option-in-g – Joerg S Nov 16 '15 at 18:32
  • You mean use the -H option for gcc? – Python_user Nov 16 '15 at 18:34
  • BTW.: The PATH variable is usually (that would really be some strange setup) not used to resolve any incude paths. Usually it's something like INCLUDE. Depends on the OS / build system / ... – Joerg S Nov 16 '15 at 18:35
  • Is it possible that it just doesn't find the boost includes at all? Probably there are some boost includes preinstalled on Ubuntu but not on CentOS. – Joerg S Nov 16 '15 at 18:37
  • It might be possible... Should i use the LD_LIBRARY_PATH variable or some other variables for the same? – Python_user Nov 16 '15 at 18:38
  • PATH is for binaries. LD_LIBRARY_PATH for libraries. Please check: http://stackoverflow.com/questions/558803/how-to-add-a-default-include-path-for-gcc-in-linux. You might try the gcc options '-MD' or '-MDD'. – Joerg S Nov 16 '15 at 18:42
  • I am already using -MD option for the same the g++ command uses the options `-lboost_system` `-lboost_filesystem` ...Can they cause some error? Now, that you say it, i did actually use the command `sudo apt-get install libboost-all-dev` on my ubuntu system before.... – Python_user Nov 16 '15 at 18:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95268/discussion-between-python-user-and-joerg-s). – Python_user Nov 16 '15 at 18:50