I'm new to c++, coming from Java, and trying to learn the basics of the
language and all that, basically just for fun. :-)
So, when once I played around with c++ a bit i found out I didn't
really have any ways of looking at directories.
So, I looked around and found the boost library, which seems pretty
cool. However, I seem to be unable to compile anything using these
libraries.
For instance, the following example program from the boost site:
http://www.boost.org/libs/filesystem.../simple_ls.cpp
when compiled by me:
>g++ simple_ls.cpp -o simple_lsproduces the following error:
(WARNING! Large snippet coming up!)
soren@soren-laptop:~$ g++ simple_ls.cpp -o simple_ls
/tmp/ccDxvNVJ.o: In function `main':
simple_ls.cpp:( .text+0x89): undefined reference to
`boost::filesys tem::initial_pa th()'
simple_ls.cpp:( .text+0xb7): undefined reference to
`boost::filesys tem::native(std ::basic_string< char,
std::char_trait s<char>, std::allocator< char const&)'
simple_ls.cpp:( .text+0xc6): undefined reference to
`boost::filesys tem::path::path (char const*, bool
(*)(std::basic_ string<char, std::char_trait s<char>,
std::allocator< char const&))'
simple_ls.cpp:( .text+0xd8): undefined reference to
`boost::filesys tem::system_com plete(boost::fi lesystem::path const&)'
simple_ls.cpp:( .text+0x17a): undefined reference to
`boost::filesys tem::exists(boo st::filesystem: :path const&)'
simple_ls.cpp:( .text+0x193): undefined reference to
`boost::filesys tem::path::nati ve_file_string( ) const'
simple_ls.cpp:( .text+0x208): undefined reference to
`boost::filesys tem::is_directo ry(boost::files ystem::path const&)'
simple_ls.cpp:( .text+0x222): undefined reference to
`boost::filesys tem::path::nati ve_directory_st ring() const'
simple_ls.cpp:( .text+0x2b5): undefined reference to
`boost::filesys tem::is_directo ry(boost::files ystem::path const&)'
simple_ls.cpp:( .text+0x2d7): undefined reference to
`boost::filesys tem::path::leaf () const'
simple_ls.cpp:( .text+0x34a): undefined reference to
`boost::filesys tem::path::leaf () const'
simple_ls.cpp:( .text+0x3f1): undefined reference to
`boost::filesys tem::path::leaf () const'
simple_ls.cpp:( .text+0x56a): undefined reference to
`boost::filesys tem::path::nati ve_file_string( ) const'
/tmp/ccDxvNVJ.o: In function
`boost::filesys tem::directory_ iterator::direc tory_iterator(b oost::filesyste m::path
const&)':
simple_ls.cpp:( .text._ZN5boost 10filesystem18d irectory_iterat orC1ERKNS0_4pat hE[boost::filesyst em::directory_i terator::direct ory_iterator(bo ost::filesystem ::path
const&)]+0x2b): undefined reference to
`boost::filesys tem::detail::di r_itr_init(boos t::shared_ptr<b oost::filesyste m::detail::dir_ itr_imp>&,
boost::filesyst em::path const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesys tem::directory_ iterator::deref erence() const':
simple_ls.cpp:( .text._ZNK5boos t10filesystem18 directory_itera tor11dereferenc eEv[boost::filesyst em::directory_i terator::derefe rence()
const]+0xd): undefined reference to
`boost::filesys tem::detail::di r_itr_dereferen ce(boost::share d_ptr<boost::fi lesystem::detai l::dir_itr_imp>
const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesys tem::directory_ iterator::incre ment()':
simple_ls.cpp:( .text._ZN5boost 10filesystem18d irectory_iterat or9incrementEv[boost::filesyst em::directory_i terator::increm ent()]+0xd):
undefined reference to
`boost::filesys tem::detail::di r_itr_increment (boost::shared_ ptr<boost::file system::detail: :dir_itr_imp>&) '
collect2: ld returned 1 exit status
I asked around a bit, and was told I didn't link the boost-libs
correctly, and to use something like:
>g++ simple_ls.cpp -o simple_ls -lboost/filesystembut that produces:
soren@soren-laptop:~$ g++ simple_ls.cpp -o simple_ls -lboost/filesystem
/usr/bin/ld: cannot find -lboost/filesystem
collect2: ld returned 1 exit status
Basically, not only do I know why this fails - or why I need it :-D -
nor do I know how to about fixing it :-)
Are there any nice tutorials out there dealing with this sort of thing
that I've been unable to find?
Thx in advance,
/Søren