Boost logo

Boost Users :

From: jayc.lawrence_at_[hidden]
Date: 2007-11-29 12:34:57


Hi Daniel,

Try adding -lboost_system to your compile line.

Jay

Daniel wrote:
> Here's the output:
> $ g++ -v -s -I/usr/include/boost -lboost_date_time -pthread ./timer.cpp
> -o ./timer
> Using built-in specs.
> Target: i486-pc-linux-gnu
> Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-
> 4.1.2/configure --prefix=/usr
> --bindir=/usr/i486-pc-linux-gnu/gcc-bin/4.1.2
> --includedir=/usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include
> --datadir=/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2
> --mandir=/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/man
> --infodir=/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/info
> --with-gxx-include-dir=/usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include/g++-v4
> --host=i486-pc-linux-gnu --build=i486-pc-linux-gnu --disable-altivec
> --enable-nls --without-included-gettext --with-system-zlib
> --disable-checking --disable-werror --enable-secureplt
> --disable-libunwind-exceptions --disable-multilib --enable-libmudflap
> --disable-libssp --disable-libgcj --with-arch=i486
> --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
> --enable-__cxa_atexit --enable-clocale=gnu
> Thread model: posix
> gcc version 4.1.2 (Gentoo 4.1.2 p1.0.2)
> /usr/libexec/gcc/i486-pc-linux-gnu/4.1.2/cc1plus -quiet -v
> -I/usr/include/boost -D_GNU_SOURCE -D_REENTRANT ./timer.cpp -quiet
> -dumpbase timer.cpp -march=i486 -auxbase timer -version -o /tmp/cc9RRPjp.s
> ignoring nonexistent directory
> "/usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../../i486-pc-linux-gnu/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/include/boost
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include/g++-v4
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include/g++-v4/i486-pc-linux-gnu
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include/g++-v4/backward
> /usr/local/include
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/include
> /usr/include
> End of search list.
> GNU C++ version 4.1.2 (Gentoo 4.1.2 p1.0.2) (i486-pc-linux-gnu)
> compiled by GNU C version 4.1.2 (Gentoo 4.1.2 p1.0.2).
> GGC heuristics: --param ggc-min-expand=46 --param ggc-min-heapsize=30755
> Compiler executable checksum: 4ca4b00b3bea7fbbb8f68a78703ea1b5
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../../i486-pc-linux-gnu/bin/as
> -V -Qy -o /tmp/ccgiUm3Z.o /tmp/cc9RRPjp.s
> GNU assembler version 2.16.1 (i486-pc-linux-gnu) using BFD version 2.16.1
> /usr/libexec/gcc/i486-pc-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o ./timer -s
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../crt1.o
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../crti.o
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/crtbegin.o
> -L/usr/lib/gcc/i486-pc-linux-gnu/4.1.2
> -L/usr/lib/gcc/i486-pc-linux-gnu/4.1.2
> -L/usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../../i486-pc-linux-gnu/lib
> -L/usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../.. -lboost_date_time
> /tmp/ccgiUm3Z.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/crtend.o
> /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/../../../crtn.o
> /tmp/ccgiUm3Z.o: In function
> `__static_initialization_and_destruction_0(int, int)':
> timer.cpp:(.text+0x13b): undefined reference to
> `boost::system::get_system_category()'
> timer.cpp:(.text+0x145): undefined reference to
> `boost::system::get_posix_category()'
> timer.cpp:(.text+0x14f): undefined reference to
> `boost::system::get_posix_category()'
> timer.cpp:(.text+0x159): undefined reference to
> `boost::system::get_system_category()'
> collect2: ld returned 1 exit status
>
> On Nov 29, 2007 12:06 PM, <jayc.lawrence_at_[hidden]
> <mailto:jayc.lawrence_at_[hidden]>> wrote:
>
> Hi Daniel,
>
> I just did a little digging, regarding that particular error it has been
> suggested previously to add -pthread to your compile string. Could you
> give us more output like what other undefined references there are?
>
> Jay
>
> Daniel wrote:
> > including the -I/path/to/boost seemed to do the trick, however,
> once I
> > started utilizing it (asio/date_time) I started getting things
> such as
> > undefined reference to `pthread_detach'
> >
> > Code directly taken from the tutorial here:
> >
> http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/tutorial/tuttimer1src.html
> <http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/tutorial/tuttimer1src.html>
> >
> > Is there a list of the exact library names in boost/asio?
> >
> > On Nov 29, 2007 11:27 AM, <jayc.lawrence_at_[hidden]
> <mailto:jayc.lawrence_at_[hidden]>
> > <mailto:jayc.lawrence_at_[hidden]
> <mailto:jayc.lawrence_at_[hidden]>>> wrote:
> >
> > Hi Daniel,
> >
> > Where were your boost header files and libraries compiled to?
> I had
> > similar issues and John Maddock helped me solve a path issue.
> Try adding
> >
> > -I/path/to/boost
> >
> > to your compile string e.g
> >
> > g++ -v -s -I/path/to/boost myfile.cpp -o myfile.exe
> >
> > you might need to add the relevant
> -lboost_library_name_goes_here to the
> > end of that compile string, where
> boost_library_name_goes_here is the
> > name of the library you are using.
> >
> > I thought this would be easier on linux than windows to be
> honest and
> > here you are having some problems !
> >
> > Hope this helps.
> >
> > Jay
> >
> > Daniel wrote:
> > > I wrote a simple "Hello, world!" program to test if
> boost/asio was
> > > working correctly:
> > >
> > > #include <iostream>
> > > #include <boost/date_time/posix_time/posix_time.hpp>
> > >
> > > int main()
> > > {
> > > std::cout << "Hello, world!\n";
> > > return 0;
> > > }
> > >
> > > But, I get this: (GCC C++ 4.1.2/Linux version
> 2.6.22-gentoo-r8)
> > > test.cpp:(.text+0x10b): undefined reference to
> > > `boost::system::get_system_category()'
> > > test.cpp:(.text+0x115): undefined reference to
> > > `boost::system::get_posix_category()'
> > > test.cpp:(.text+0x11f): undefined reference to
> > > `boost::system::get_posix_category()'
> > > test.cpp:(.text+0x129): undefined reference to
> > > `boost::system::get_system_category()'
> > >
> > >
> > > This happens when I used '#include
> > > <boost/date_time/posix_time/posix_time.hpp>'
> > > I can't figure out what I'm missing
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Boost-users mailing list
> > > Boost-users_at_[hidden]
> <mailto:Boost-users_at_[hidden]> <mailto:
> Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>>
> > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> <http://lists.boost.org/mailman/listinfo.cgi/boost-users>
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> <mailto:Boost-users_at_[hidden]> <mailto:
> Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>>
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> <http://lists.boost.org/mailman/listinfo.cgi/boost-users>
> > <http://lists.boost.org/mailman/listinfo.cgi/boost-users>
> >
> >
> >
> >
> ------------------------------------------------------------------------
>
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net