[boost 1.35] Linking problem with GCC 3.2

Hi members, I'm using both GCC 3.2 and 3.4 in different linux machines. The application uses a number of BOOST libraries such as program_options, iosterams, thread and system. When I compiled the application with GCC 3.4 (of course linking correct library files like "libboost_program_options-gcc34-mt"), it compiled well and works well. I did "ldd" to see what library files are linked... and it says... libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0048a000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x005e8000) libm.so.6 => /lib/tls/libm.so.6 (0x00372000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00555000) libc.so.6 => /lib/tls/libc.so.6 (0x0023e000) /lib/ld-linux.so.2 (0x00224000) Now, I compiled the same application and link different gcc version of boost library files because it uses GCC 3.2 instead. I compiled it and there was no compile-time error but it cannot be executed because it can't find the target library files. I did "ldd" for the application and now it has all the boost library files... libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0038d000) libboost_system-gcc32-mt-1_35.so.1.35.0 => not found libboost_thread-gcc32-mt-1_35.so.1.35.0 => not found libboost_serialization-gcc32-mt-1_35.so.1.35.0 => not found libboost_program_options-gcc32-mt-1_35.so.1.35.0 => not found libboost_iostreams-gcc32-mt-1_35.so.1.35.0 => not found libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00b8e000) libm.so.6 => /lib/tls/libm.so.6 (0x007a6000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00179000) libc.so.6 => /lib/tls/libc.so.6 (0x00182000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00d66000) Both machine has the same boost 1.35. Only differences is they have different versions of GCC (3.2 and 3.4). Is there any idea or hints where this problem comes from??? regards, Alex Kim

Alexander Dong Back Kim wrote:
Hi members,
I'm using both GCC 3.2 and 3.4 in different linux machines. The application uses a number of BOOST libraries such as program_options, iosterams, thread and system. When I compiled the application with GCC 3.4 (of course linking correct library files like "libboost_program_options-gcc34-mt"), it compiled well and works well. I did "ldd" to see what library files are linked... and it says...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0048a000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x005e8000) libm.so.6 => /lib/tls/libm.so.6 (0x00372000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00555000) libc.so.6 => /lib/tls/libc.so.6 (0x0023e000) /lib/ld-linux.so.2 (0x00224000)
To be pedantic, the above output has no indication that boost libraries are found, it only says that the system libraries are found, which is hardly a surprise.
Now, I compiled the same application and link different gcc version of boost library files because it uses GCC 3.2 instead. I compiled it and there was no compile-time error but it cannot be executed because it can't find the target library files. I did "ldd" for the application and now it has all the boost library files...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0038d000) libboost_system-gcc32-mt-1_35.so.1.35.0 => not found libboost_thread-gcc32-mt-1_35.so.1.35.0 => not found libboost_serialization-gcc32-mt-1_35.so.1.35.0 => not found libboost_program_options-gcc32-mt-1_35.so.1.35.0 => not found libboost_iostreams-gcc32-mt-1_35.so.1.35.0 => not found libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00b8e000) libm.so.6 => /lib/tls/libm.so.6 (0x007a6000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00179000) libc.so.6 => /lib/tls/libc.so.6 (0x00182000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00d66000)
Both machine has the same boost 1.35. Only differences is they have different versions of GCC (3.2 and 3.4). Is there any idea or hints where this problem comes from???
This problem is caused by the fact that there's no file called libboost_system-gcc32-mt-1_35.so.1.35.0 neither in standard system libraries directories (such as /usr/lib) nor in directories in LD_LIBRARY_PATH. You have to place the libraries somewhere where they can be found. BTW, this issue is not specific to C++ Boost -- it's just regular shared linking thing on Linux. - Volodya

On Mon, Sep 1, 2008 at 4:46 PM, Vladimir Prus <vladimir@codesourcery.com>wrote:
Alexander Dong Back Kim wrote:
Hi members,
I'm using both GCC 3.2 and 3.4 in different linux machines. The application uses a number of BOOST libraries such as program_options, iosterams, thread and system. When I compiled the application with GCC 3.4 (of course linking correct library files like "libboost_program_options-gcc34-mt"), it compiled well and works well. I did "ldd" to see what library files are linked... and it says...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0048a000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x005e8000) libm.so.6 => /lib/tls/libm.so.6 (0x00372000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00555000) libc.so.6 => /lib/tls/libc.so.6 (0x0023e000) /lib/ld-linux.so.2 (0x00224000)
To be pedantic, the above output has no indication that boost libraries are found, it only says that the system libraries are found, which is hardly a surprise.
I found out the problem. I apologize about my silliness that I actually linked static library (.a) in a machine and tried to link dynamic libraries (.so) in another machine.
Now, I compiled the same application and link different gcc version of boost library files because it uses GCC 3.2 instead. I compiled it and there was no compile-time error but it cannot be executed because it can't find the target library files. I did "ldd" for the application and now it has all the boost library files...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0038d000) libboost_system-gcc32-mt-1_35.so.1.35.0 => not found libboost_thread-gcc32-mt-1_35.so.1.35.0 => not found libboost_serialization-gcc32-mt-1_35.so.1.35.0 => not found libboost_program_options-gcc32-mt-1_35.so.1.35.0 => not found libboost_iostreams-gcc32-mt-1_35.so.1.35.0 => not found libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00b8e000) libm.so.6 => /lib/tls/libm.so.6 (0x007a6000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00179000) libc.so.6 => /lib/tls/libc.so.6 (0x00182000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00d66000)
Both machine has the same boost 1.35. Only differences is they have different versions of GCC (3.2 and 3.4). Is there any idea or hints where this problem comes from???
This problem is caused by the fact that there's no file called libboost_system-gcc32-mt-1_35.so.1.35.0 neither in standard system libraries directories (such as /usr/lib) nor in directories in LD_LIBRARY_PATH. You have to place the libraries somewhere where they can be found. BTW, this issue is not specific to C++ Boost -- it's just regular shared linking thing on Linux.
It seems LD_LIBRARY_PATH is the right answer for linking the library dynamically. Thanks for your advice. However, I think I need to use static libarries since I have to install the application in many other machines where installing boost is bit hard. Thanks for your advices. I deeply appreciate your help =) regards, Alex Kim

Alexander Dong Back Kim skrev:
Now, I compiled the same application and link different gcc version of boost library files because it uses GCC 3.2 instead. I compiled it and there was no compile-time error but it cannot be executed because it can't find the target library files. I did "ldd" for the application and now it has all the boost library files...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0038d000) libboost_system-gcc32-mt-1_35.so.1.35.0 => not found libboost_thread-gcc32-mt-1_35.so.1.35.0 => not found libboost_serialization-gcc32-mt-1_35.so.1.35.0 => not found libboost_program_options-gcc32-mt-1_35.so.1.35.0 => not found libboost_iostreams-gcc32-mt-1_35.so.1.35.0 => not found libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00b8e000) libm.so.6 => /lib/tls/libm.so.6 (0x007a6000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00179000) libc.so.6 => /lib/tls/libc.so.6 (0x00182000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00d66000)
Maybe this can help: http://prefetch.net/articles/linkers.badldlibrary.html Best regards, Christian

On Mon, Sep 1, 2008 at 4:50 PM, Christian Larsen <contact@dword.dk> wrote:
Alexander Dong Back Kim skrev:
Now, I compiled the same application and link different gcc version of boost library files because it uses GCC 3.2 instead. I compiled it and there was no compile-time error but it cannot be executed because it can't find the target library files. I did "ldd" for the application and now it has all the boost library files...
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0038d000) libboost_system-gcc32-mt-1_35.so.1.35.0 => not found libboost_thread-gcc32-mt-1_35.so.1.35.0 => not found libboost_serialization-gcc32-mt-1_35.so.1.35.0 => not found libboost_program_options-gcc32-mt-1_35.so.1.35.0 => not found libboost_iostreams-gcc32-mt-1_35.so.1.35.0 => not found libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00b8e000) libm.so.6 => /lib/tls/libm.so.6 (0x007a6000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00179000) libc.so.6 => /lib/tls/libc.so.6 (0x00182000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00d66000)
Maybe this can help: http://prefetch.net/articles/linkers.badldlibrary.html
I found out the link is really helpful. Thanks for your hint. regards, Alex Kim
participants (3)
-
Alexander Dong Back Kim
-
Christian Larsen
-
Vladimir Prus