Reputation: 1497
I'm trying to compile glibc with debug symbols and use it for small application. So I downloaded and glibc, compiled without problems, installed in /custobuilds and now I'm compiling my own app:
/usr/bin/c++ -g -Wall -nostartfiles -nodefaultlibs -Wl,--dynamic-linker=/custobuilds/lib/ld-2.27.so -o CMakeFiles/annotation.dir/annotation.o -c annotation.cpp
/usr/bin/c++ -g -Wall -nostartfiles -nodefaultlibs -Wl,--dynamic-linker=/custobuilds/lib/ld-2.27.so CMakeFiles/annotation.dir/annotation.o /custobuilds/lib/crt1.o /custobuilds/lib/crti.o -o annotation -L/custobuilds/lib -rdynamic -lc -Wl,-rpath,/custobuilds/lib
Things get linked correctly:
zhani@zhani-Aspire-E1-571G:~/Thesis/test/build$ LD_TRACE_LOADED_OBJECTS=1 ./annotation
linux-vdso.so.1 (0x00007ffe8558f000)
libc.so.6 => /custobuilds/lib/libc.so.6 (0x00007f73e02c2000)
/custobuilds/lib/ld-2.27.so (0x00007f73e0677000)
In source I also have included correct files, only
#include "/custobuilds/include/stdio.h"
And I only have one scanf()/printf() there. I have checked with gdb, it crashes before reaching main()
Any ideas?
Upvotes: 1
Views: 414
Reputation: 213897
get linked correctly
No, it doesn't: you are missing crtn.o
, and the order of objects on the link line generally should be:
crt1.o crti.o main.o -lc crtn.o
Upvotes: 1