Linking to shared library

Hi, I get an error linking the example program days_alive to the shared library libboost_date_time. g++ -L/usr/lib -lboost_date_time -odays_alive days_alive.o days_alive.o(.gnu.linkonce.t._ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtSs+0xec): In function `unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)': /usr/include/boost/token_functions.hpp:587: undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()' collect2: ld returned 1 exit status Platform is FC2 gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) I built Boost from the SRC RPM boost-1.32.0-3.src.rpm with no special switches. I found a comment in the boost mailings advising linking to static library. This was successful. Is the general advice to only use the static libraries? Giles Anderson

On Sat, 16 Apr 2005 10:11:58 +0100, Gander wrote
Hi,
I get an error linking the example program days_alive to the shared library libboost_date_time.
g++ -L/usr/lib -lboost_date_time -odays_alive days_alive.o
days_alive.o(.gnu.linkonce.t._ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtSs+0xec): In function `unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)': /usr/include/boost/token_functions.hpp:587: undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()' collect2: ld returned 1 exit status
Platform is FC2 gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
I built Boost from the SRC RPM boost-1.32.0-3.src.rpm with no special switches.
I found a comment in the boost mailings advising linking to static library. This was successful.
Is the general advice to only use the static libraries?
The shared library works fine for me on Mandrake -- but I built it and installed it myself. Are you 100% sure the library path and name are correct? If you build boost directly the library names are different: boost_date_time-gcc-d-1-32.so for example... Jeff

On Saturday 16 April 2005 15:58, Jeff Garland wrote:
The shared library works fine for me on Mandrake -- but I built it and installed it myself. Are you 100% sure the library path and name are correct? If you build boost directly the library names are different: boost_date_time-gcc-d-1-32.so for example...
I believe so. It was a stock build of the src rpm. The RPM reports: - rpm -ql boost-1.32.0-3 /usr/lib/libboost_date_time.so.1.32.0 /usr/lib/libboost_filesystem.so.1.32.0 /usr/lib/libboost_prg_exec_monitor.so.1.32.0 /usr/lib/libboost_program_options.so.1.32.0 /usr/lib/libboost_python.so.1.32.0 /usr/lib/libboost_regex.so.1.32.0 /usr/lib/libboost_signals.so.1.32.0 /usr/lib/libboost_test_exec_monitor.so.1.32.0 /usr/lib/libboost_thread.so.1.32.0 /usr/lib/libboost_unit_test_framework.so.1.32.0 ldconfig reports: - sbin/ldconfig --print-cache |grep libboost | grep date libboost_date_time.so.1 (libc6) => /usr/lib/libboost_date_time.so.1 and the assoc. files are: - lrwxrwxrwx 1 root root 28 Apr 10 18:42 /usr/lib/libboost_date_time.so.1 -> libboost_date_time.so.1.32.0 -rwxr-xr-x 1 root root 74296 Apr 10 18:39 /usr/lib/libboost_date_time.so.1.32.0

On Sun, 17 Apr 2005 16:08:40 +0100, Gander wrote: ... snip ...
I believe so. It was a stock build of the src rpm.
The RPM reports: -
rpm -ql boost-1.32.0-3 /usr/lib/libboost_date_time.so.1.32.0 /usr/lib/libboost_filesystem.so.1.32.0
...
ldconfig reports: - sbin/ldconfig --print-cache |grep libboost | grep date libboost_date_time.so.1 (libc6) => /usr/lib/libboost_date_time.so.1
and the assoc. files are: -
lrwxrwxrwx 1 root root 28 Apr 10 18:42 /usr/lib/libboost_date_time.so.1 -> libboost_date_time.so.1.32.0
-rwxr-xr-x 1 root root 74296 Apr 10 18:39 /usr/lib/libboost_date_time.so.1.32.0
I was not able to find a srpm for v1.32 so I tried to duplicate your problem with v1.30. I also did a stock build of the srpm. I was able to link days_alive.cpp to the shared library. My output from: rpm -qpl boost-1.30.2-2.i386.rpm /usr/lib/libboost_date_time.so /usr/lib/libboost_date_time.so.1.30.2 I notice your output does not show libboost_date_time.so. Can you verify if this file exists in your /usr/lib directory? Also, where did you find your copy of the 1.32 srpm? Bart

On Sunday 17 April 2005 16:34, Bart wrote:
My output from: rpm -qpl boost-1.30.2-2.i386.rpm /usr/lib/libboost_date_time.so /usr/lib/libboost_date_time.so.1.30.2
Mine is: - rpm -qpl /usr/src/redhat/RPMS/i386/boost-1.32.0-3.i386.rpm /usr/lib/libboost_date_time.so.1.32.0 /usr/lib/libboost_filesystem.so.1.32.0 /usr/lib/libboost_prg_exec_monitor.so.1.32.0 /usr/lib/libboost_program_options.so.1.32.0 /usr/lib/libboost_python.so.1.32.0 /usr/lib/libboost_regex.so.1.32.0 /usr/lib/libboost_signals.so.1.32.0 /usr/lib/libboost_test_exec_monitor.so.1.32.0 /usr/lib/libboost_thread.so.1.32.0 /usr/lib/libboost_unit_test_framework.so.1.32.0
I notice your output does not show libboost_date_time.so. Can you verify if this file exists in your /usr/lib directory?
I have these: - l /usr/lib/libboost_*date* lrwxrwxrwx 1 root root 28 Apr 10 18:42 /usr/lib/libboost_date_time.so.1 -> libboost_date_time.so.1.32.0 -rwxr-xr-x 1 root root 123314 Apr 10 18:39 /usr/lib/libboost_date_time.a -rwxr-xr-x 1 root root 74296 Apr 10 18:39 /usr/lib/libboost_date_time.so.1.32.0 locate 'libboost_date_time.so' /usr/lib/libboost_date_time.so.1
Also, where did you find your copy of the 1.32 srpm?
I went for: - The Boost C++ Libraries Fedora Core Development Sources boost-1.32.0-3.src.rpm from: - <http://rpmfind.net/linux/rpm2html/search.php?query=boost&submit=Search+...&system=Fedora&arch=> I was hoping I would be to use 1.32 as it's compatible with work. I have re-installed 1.31 and re-compiled days_alive and it's still complaining. g++ -ggdb -x c++ -pipe -Wall -I. -D__USE_STD_IOSTREAM -lboost_date_time -o days_alive days_alive.cpp /tmp/ccV7Juhv.o(.gnu.linkonce.t._ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtSs+0xec): In function `unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)': /usr/include/boost/token_functions.hpp:459: undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()' collect2: ld returned 1 exit status rpm -qpl boost-1.31.0-7.i386.rpm /usr/lib/libboost_date_time.a /usr/lib/libboost_date_time.so.1.31.0 1.31 was a srpms build (no special switches) retreived from a mirror similar to: - ftp://ftp.mirrorservice.org/sites/download.fedora.redhat.com/pub/fedora/linux/core/2/SRPMS/

On Mon, 18 Apr 2005 18:05:49 +0100, Gander wrote:
I have these: -
l /usr/lib/libboost_*date* lrwxrwxrwx 1 root root 28 Apr 10 18:42 /usr/lib/libboost_date_time.so.1 -> libboost_date_time.so.1.32.0 -rwxr-xr-x 1 root root 123314 Apr 10 18:39 /usr/lib/libboost_date_time.a -rwxr-xr-x 1 root root 74296 Apr 10 18:39 /usr/lib/libboost_date_time.so.1.32.0
locate 'libboost_date_time.so' /usr/lib/libboost_date_time.so.1
I have re-installed 1.31 and re-compiled days_alive and it's still complaining.
Be careful. I think the days_alive example changed between 1.31 & 1.32. I don't believe the 1.32 version will compile against the 1.31 library.
rpm -qpl boost-1.31.0-7.i386.rpm /usr/lib/libboost_date_time.a /usr/lib/libboost_date_time.so.1.31.0
You are missing the libboost_date_time.so symlink. I can duplicate your error if I remove the symlink from my lib directory so I get the following: libdir has libboost_date_time-gcc-1_32.a libboost_date_time-gcc-1_32.so.1.32.0 `g++ -I$BOOST_ROOT -Llibdir days_alive.cpp -lboost_date_time-gcc-1_32` Compiles fine. `stat` shows file size 133276 (statically linked) Recompile (different command): `g++ -I$BOOST_ROOT -Llibdir -lboost_date_time-gcc-1_32 days_alive.cpp` I get the same error you do. Replace the symlink... ` ln -s libboost_date_time-gcc-1_32.so.1.32.0 libboost_date_time-gcc-1_32.so` Recompile: `g++ -I$BOOST_ROOT -Llibdir -lboost_date_time-gcc-1_32 days_alive.cpp` Compiles fine. `stat` shows file size 78764 (dynamically linked). When I built the 1.30 srpm, it included the symlink in the rpm file that was built. I'd say there was an error introduced when the srpm was assembled. If you add your own symlink everything should be fine. Bart

On Tue, 19 Apr 2005 22:03:55 +0100, Gander wrote:
On Monday 18 April 2005 19:55, Bart wrote:
If you add your own symlink everything should be fine.
Thanks Bart. Creating the new link has sorted it!
Just one question though. Should'nt the build have done this?
Yes, I think it should have been created during the build or during the install process. If you've got the time, check the info in your srpm, and file a bug report with it's maintainers. Hopefully they will either fix it or provide an explanation why the link was not included/generated. Bart

Thanks again for the help. There is an outstanding bug :(. Sorry - should have checked. #122817 – libboost_*.so symlinks missing Giles
participants (3)
-
Bart
-
Gander
-
Jeff Garland