S
soren.andersen
Hello out there
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/example/simple_ls.cpp
when compiled by me:
(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::filesystem::initial_path()'
simple_ls.cpp.text+0xb7): undefined reference to
`boost::filesystem::native(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
simple_ls.cpp.text+0xc6): undefined reference to
`boost::filesystem:ath:ath(char const*, bool
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&))'
simple_ls.cpp.text+0xd8): undefined reference to
`boost::filesystem::system_complete(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x17a): undefined reference to
`boost::filesystem::exists(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x193): undefined reference to
`boost::filesystem:ath::native_file_string() const'
simple_ls.cpp.text+0x208): undefined reference to
`boost::filesystem::is_directory(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x222): undefined reference to
`boost::filesystem:ath::native_directory_string() const'
simple_ls.cpp.text+0x2b5): undefined reference to
`boost::filesystem::is_directory(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x2d7): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x34a): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x3f1): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x56a): undefined reference to
`boost::filesystem:ath::native_file_string() const'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::directory_iterator(boost::filesystem:ath
const&)':
simple_ls.cpp.text._ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE[boost::filesystem::directory_iterator::directory_iterator(boost::filesystem:ath
const&)]+0x2b): undefined reference to
`boost::filesystem::detail::dir_itr_init(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>&,
boost::filesystem:ath const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::dereference() const':
simple_ls.cpp.text._ZNK5boost10filesystem18directory_iterator11dereferenceEv[boost::filesystem::directory_iterator::dereference()
const]+0xd): undefined reference to
`boost::filesystem::detail::dir_itr_dereference(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>
const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::increment()':
simple_ls.cpp.text._ZN5boost10filesystem18directory_iterator9incrementEv[boost::filesystem::directory_iterator::increment()]+0xd):
undefined reference to
`boost::filesystem::detail::dir_itr_increment(boost::shared_ptr<boost::filesystem::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:
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
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/example/simple_ls.cpp
when compiled by me:
produces the following error:g++ simple_ls.cpp -o simple_ls
(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::filesystem::initial_path()'
simple_ls.cpp.text+0xb7): undefined reference to
`boost::filesystem::native(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
simple_ls.cpp.text+0xc6): undefined reference to
`boost::filesystem:ath:ath(char const*, bool
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&))'
simple_ls.cpp.text+0xd8): undefined reference to
`boost::filesystem::system_complete(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x17a): undefined reference to
`boost::filesystem::exists(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x193): undefined reference to
`boost::filesystem:ath::native_file_string() const'
simple_ls.cpp.text+0x208): undefined reference to
`boost::filesystem::is_directory(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x222): undefined reference to
`boost::filesystem:ath::native_directory_string() const'
simple_ls.cpp.text+0x2b5): undefined reference to
`boost::filesystem::is_directory(boost::filesystem:ath const&)'
simple_ls.cpp.text+0x2d7): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x34a): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x3f1): undefined reference to
`boost::filesystem:ath::leaf() const'
simple_ls.cpp.text+0x56a): undefined reference to
`boost::filesystem:ath::native_file_string() const'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::directory_iterator(boost::filesystem:ath
const&)':
simple_ls.cpp.text._ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE[boost::filesystem::directory_iterator::directory_iterator(boost::filesystem:ath
const&)]+0x2b): undefined reference to
`boost::filesystem::detail::dir_itr_init(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>&,
boost::filesystem:ath const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::dereference() const':
simple_ls.cpp.text._ZNK5boost10filesystem18directory_iterator11dereferenceEv[boost::filesystem::directory_iterator::dereference()
const]+0xd): undefined reference to
`boost::filesystem::detail::dir_itr_dereference(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>
const&)'
/tmp/ccDxvNVJ.o: In function
`boost::filesystem::directory_iterator::increment()':
simple_ls.cpp.text._ZN5boost10filesystem18directory_iterator9incrementEv[boost::filesystem::directory_iterator::increment()]+0xd):
undefined reference to
`boost::filesystem::detail::dir_itr_increment(boost::shared_ptr<boost::filesystem::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:
but that produces:g++ simple_ls.cpp -o simple_ls -lboost/filesystem
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