I'm trying to compile a c++ program with boost library that I compiled myself.
Here is how I compiled boost in ~/libs/
tar -xvzf boost_1_80_0.tar.gz
cd boost_1_80_0/
./bootstrap.sh --prefix=.
./b2 -std=C++11
./b2 headers
./b2 install
Among others, it creates the file boost_1_80_0/stage/lib/libboost_filesystem.a
.
Here is my c++ code:
#include <boost/filesystem.hpp>
#include <iostream>
int main()
{
boost::filesystem::path directory = ".";
boost::filesystem::directory_iterator end_itr;
for( boost::filesystem::directory_iterator itr(directory); itr!=end_itr;++itr )
{
boost::filesystem::path pathname=itr->path();
std::cout<< pathname << std::endl;
}
}
Now I try to compile with
LC_ALL=C c++ -std=c++11 -I ~/libs/boost_1_80_0/stage/lib ~/libs/boost_1_80_0/stage/lib/libboost_filesystem.a ecm.cpp -o ecm
I have a bunch of errors:
/usr/bin/ld: /tmp/ccXuD16q.o: in function `boost::filesystem::detail::dir_itr_imp::~dir_itr_imp()':
ecm.cpp:(.text._ZN5boost10filesystem6detail11dir_itr_impD2Ev[_ZN5boost10filesystem6detail11dir_itr_impD5Ev]+0x27): undefined reference to `boost::filesystem::detail::dir_itr_close(void*&, void*&)'
/usr/bin/ld: /tmp/ccXuD16q.o: in function `boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&, boost::filesystem::directory_options)':
ecm.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathENS0_17directory_optionsE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathENS0_17directory_optionsE]+0x38): undefined reference to `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, unsigned int, boost::system::error_code*)'
/usr/bin/ld: /tmp/ccXuD16q.o: in function `boost::filesystem::directory_iterator::increment()':
ecm.cpp:(.text._ZN5boost10filesystem18directory_iterator9incrementEv[_ZN5boost10filesystem18directory_iterator9incrementEv]+0x1d): undefined reference to `boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)'
collect2: error: ld returned 1 exit status
Am I missing an include ?
Aucun commentaire:
Enregistrer un commentaire