I'm trying to run an executable which works fine on my machine on a computer at my university. That computer lacks a compiler, and also libraries that I need, like the boost libs, for instance.
So I've compiled the program on my computer and copied the binary and all the libs I could find using ldd/objdump to the other computer. Unfortunately, when running it I the linker fails to start the program:
LD_LIBRARY_PATH="." ./my_program
./my_program: relocation error: ./libc.so.6: symbol _dl_find_dso_for_object, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Of course I searched the net: relocation errors seem to occur when a wrong version of some library has been used. However, I can't see how this would be possible when I supply the exact same libraries that are present during compilation.
I read that LD_BIND_NOW can be used to debug dynamic linking; using it, the program segfaults immediately. I compiled a version with -Og -ggdb
, executed it at the server and downloaded the resulting core dump to my computer (there is also no gdb on the other computer). Here's the session:
$ gdb ./my_program core
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /my_program...done.
warning: core file may not match specified executable file.
[New LWP 8912]
warning: Can't read pathname for load map: Input/output error.
warning: .dynamic section for "/lib64/ld-linux-x86-64.so.2" is not at the expected address (wrong library or version mismatch?)
warning: Could not load shared library symbols for 14 libraries, e.g. ./libboost_program_options.so.1.54.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./my_program'.
Program terminated with signal 11, Segmentation fault.
#0 0x00000000000056f6 in ?? ()
(gdb) bt
#0 0x00000000000056f6 in ?? ()
#1 0x00007f51ff6fff99 in ?? ()
#2 0x00007ffffb653480 in ?? ()
#3 0x00007f520069bc11 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
#4 0x00007f52006937b1 in dl_main () from /lib64/ld-linux-x86-64.so.2
#5 0x00007f52006a4dde in _dl_load_cache_lookup () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000000 in ?? ()
(gdb)
At this point I really don't know how to proceed. I'd welcome any suggestions. Thank you!
PS: Compilation flags look like this (I also tried the flags that I get using -march=native on the target machine):
/usr/bin/c++ \
-Wall -Wextra -Woverloaded-virtual -Wpedantic -std=c++11 -pthread -Og -ggdb \
-Wl,--warn-unresolved-symbols,--warn-once ... -o my_program \
-rdynamic -lboost_program_options -lboost_system -lboost_filesystem -lboost_regex