I suppose, it's a begginer's linux problem but I didn't found the answer
neither in the documentation nor in the internet forums...
After installing boost on my system (see how at the end of this email),
I wanted to compile simple_ls.cpp, the filesystem example.
everything works when creating the .o but when linking a lot of
undefined references arised. What have I done wrong?
g++ -c simple_ls.cpp
[marc@localhost ls]$ g++ -c simple_ls.cpp
[marc@localhost ls]$ ls
ls/ simple_ls.cpp* simple_ls.o
[marc@localhost ls]$ g++ simple
simple_ls.cpp simple_ls.o
[marc@localhost ls]$ g++ simple_ls.cpp -o simple_ls
/tmp/ccjMYBxo.o(.text+0x19): In function `main':
: undefined reference to `boost::filesystem::initial_path()'
/tmp/ccjMYBxo.o(.text+0x44): In function `main':
: undefined reference to
`boost::filesystem::native(std::basic_string const&)'
/tmp/ccjMYBxo.o(.text+0x55): In function `main':
: undefined reference to `boost::filesystem::path::path[in-charge](char
const*, bool (*)(std::basic_string const&))'
/tmp/ccjMYBxo.o(.text+0x64): In function `main':
: undefined reference to
`boost::filesystem::system_complete(boost::filesystem::path const&)'
/tmp/ccjMYBxo.o(.text+0x119): In function `main':
: undefined reference to
`boost::filesystem::exists(boost::filesystem::path const&)'
/tmp/ccjMYBxo.o(.text+0x13c): In function `main':
: undefined reference to `boost::filesystem::path::native_file_string()
const'
/tmp/ccjMYBxo.o(.text+0x1bf): In function `main':
: undefined reference to
`boost::filesystem::is_directory(boost::filesystem::path const&)'
/tmp/ccjMYBxo.o(.text+0x1e2): In function `main':
: undefined reference to
`boost::filesystem::path::native_directory_string() const'
/tmp/ccjMYBxo.o(.text+0x291): In function `main':
: undefined reference to
`boost::filesystem::is_directory(boost::filesystem::path const&)'
/tmp/ccjMYBxo.o(.text+0x2ca): In function `main':
: undefined reference to `boost::filesystem::path::leaf() const'
/tmp/ccjMYBxo.o(.text+0x351): In function `main':
: undefined reference to `boost::filesystem::path::leaf() const'
/tmp/ccjMYBxo.o(.text+0x418): In function `main':
: undefined reference to `boost::filesystem::path::leaf() const'
/tmp/ccjMYBxo.o(.text+0x586): In function `main':
: undefined reference to `boost::filesystem::path::native_file_string()
const'
/tmp/ccjMYBxo.o(.gnu.linkonce.t._ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE+0x2d):
In function
`boost::filesystem::directory_iterator::directory_iterator[in-charge](boost::filesystem::path
const&)':
: undefined reference to
`boost::filesystem::detail::dir_itr_init(boost::shared_ptrboost::filesystem::detail::dir_itr_imp&,
boost::filesystem::path const&)'
/tmp/ccjMYBxo.o(.gnu.linkonce.t._ZNK5boost10filesystem18directory_iterator11dereferenceEv+0xd):
In function `boost::filesystem::directory_iterator::dereference() const':
: undefined reference to
`boost::filesystem::detail::dir_itr_dereference(boost::shared_ptrboost::filesystem::detail::dir_itr_imp
const&)'
/tmp/ccjMYBxo.o(.gnu.linkonce.t._ZN5boost10filesystem18directory_iterator9incrementEv+0xd):
In function `boost::filesystem::directory_iterator::increment()':
: undefined reference to
`boost::filesystem::detail::dir_itr_increment(boost::shared_ptrboost::filesystem::detail::dir_itr_imp&)'
collect2: ld returned 1 exit status
thank you in advance again.
PS:
my system is:
[marc@localhost html]$ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/specs
Configured with: ../configure --prefix=/usr --libdir=/usr/lib
--with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info
--enable-shared --enable-threads=posix --disable-checking
--enable-long-long --enable-__cxa_atexit --enable-clocale=gnu
--enable-languages=c,c++,ada,f77,objc,java,pascal
--host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)
And i've installed boost using these packages:
Nombre: libboost1
Versión: 1.31.0-5mdk
/usr/lib/libboost_date_time.so.1
/usr/lib/libboost_date_time.so.1.31.0
/usr/lib/libboost_filesystem.so.1
/usr/lib/libboost_filesystem.so.1.31.0
/usr/lib/libboost_prg_exec_monitor.so.1
/usr/lib/libboost_prg_exec_monitor.so.1.31.0
/usr/lib/libboost_python.so.1
/usr/lib/libboost_python.so.1.31.0
/usr/lib/libboost_regex.so.1
/usr/lib/libboost_regex.so.1.31.0
/usr/lib/libboost_signals.so.1
/usr/lib/libboost_signals.so.1.31.0
/usr/lib/libboost_test_exec_monitor.so.1
/usr/lib/libboost_test_exec_monitor.so.1.31.0
/usr/lib/libboost_thread.so.1
/usr/lib/libboost_thread.so.1.31.0
/usr/lib/libboost_unit_test_framework.so.1
/usr/lib/libboost_unit_test_framework.so.1.31.0
/usr/share/doc/libboost1-1.31.0
/usr/share/doc/libboost1-1.31.0/LICENSE_1_0.txt
Nombre: libboost1-devel
Versión: 1.31.0-5mdk
Archivos:
/usr/include/boost
/usr/include/boost/aligned_storage.hpp
/usr/include/boost/any.hpp
/usr/include/boost/array.hpp
/usr/include/boost/assert.hpp
/usr/include/boost/bind
/usr/include/boost/bind.hpp
/usr/include/boost/bind/apply.hpp
/usr/include/boost/bind/arg.hpp
/usr/include/boost/bind/bind_cc.hpp
/usr/include/boost/bind/bind_mf_cc.hpp
/usr/include/boost/bind/bind_template.hpp
/usr/include/boost/bind/make_adaptable.hpp
/usr/include/boost/bind/mem_fn_cc.hpp
/usr/include/boost/bind/mem_fn_template.hpp
/usr/include/boost/bind/mem_fn_vw.hpp
/usr/include/boost/bind/placeholders.hpp
/usr/include/boost/bind/protect.hpp
/usr/include/boost/blank.hpp
/usr/include/boost/blank_fwd.hpp
/usr/include/boost/call_traits.hpp
...
/usr/lib/libboost_date_time.so
/usr/lib/libboost_filesystem.so
/usr/lib/libboost_prg_exec_monitor.so
/usr/lib/libboost_python.so
/usr/lib/libboost_regex.so
/usr/lib/libboost_signals.so
/usr/lib/libboost_test_exec_monitor.so
/usr/lib/libboost_thread.so
/usr/lib/libboost_unit_test_framework.so
/usr/share/doc/libboost1-devel-1.31.0
/usr/share/doc/libboost1-devel-1.31.0/README
/usr/share/doc/libboost1-devel-1.31.0/boost.css
/usr/share/doc/libboost1-devel-1.31.0/c++boost.gif
Nombre: libboost1-static-devel
Versión: 1.31.0-5mdk
/usr/lib/libboost_date_time.a
/usr/lib/libboost_filesystem.a
/usr/lib/libboost_prg_exec_monitor.a
/usr/lib/libboost_python.a
/usr/lib/libboost_regex.a
/usr/lib/libboost_signals.a
/usr/lib/libboost_test_exec_monitor.a
/usr/lib/libboost_unit_test_framework.a