I am running Ubuntu 18.04.2 LTS and trying to build some code using gcc
and getting the following error:
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/lib/../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/lib64/libgcc_s.so.1: undefined reference to `memcpy@GLIBC_2.14'
collect2: error: ld returned 1 exit status
I believe that the problem does not lie in the project but the object file that is trying to use a GLIBC version unavailable on my system but is part of my system.
The object file is /usr/x86_64-linux-gnu/lib/crt1.o
part of libc6-dev-amd64-cross
version 2.27-3ubuntu1cross1.1.
I am not too familiar with gcc
and it seems that I cannot just pull a libc 2.14 and get it to build.
I am stuck.
What should I check? Do I need to use an option for gcc
? Or perhaps is this a problem in my distribution?
More info:
# readlink -f /usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/lib/../lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o
# file /usr/x86_64-linux-gnu/lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), for GNU/Linux 3.2.0, not stripped
# apt-file search /usr/x86_64-linux-gnu/lib/crt1.o
libc6-dev-amd64-cross: /usr/x86_64-linux-gnu/lib/crt1.o
# dpkg -l | grep libc6-dev-amd64-cross
ii libc6-dev-amd64-cross 2.27-3ubuntu1cross1.1 [...]
# objdump -t /usr/x86_64-linux-gnu/lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o: file format elf64-x86-64
SYMBOL TABLE:
0000000000000000 l d .text 0000000000000000 .text
0000000000000000 l d .note.ABI-tag 0000000000000000 .note.ABI-tag
0000000000000000 l d .rodata.cst4 0000000000000000 .rodata.cst4
0000000000000000 l d .eh_frame 0000000000000000 .eh_frame
0000000000000000 l d .data 0000000000000000 .data
0000000000000000 l d .bss 0000000000000000 .bss
0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack
0000000000000000 *UND* 0000000000000000 __libc_csu_fini
0000000000000030 g F .text 0000000000000002 .hidden _dl_relocate_static_pie
0000000000000000 g F .text 000000000000002b _start
0000000000000000 *UND* 0000000000000000 __libc_csu_init
0000000000000000 *UND* 0000000000000000 main
0000000000000000 w .data 0000000000000000 data_start
0000000000000000 *UND* 0000000000000000 _GLOBAL_OFFSET_TABLE_
0000000000000000 g O .rodata.cst4 0000000000000004 _IO_stdin_used
0000000000000000 *UND* 0000000000000000 __libc_start_main
0000000000000000 g .data 0000000000000000 __data_start
# gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
[...]
# ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
[...]
Edit 1: I have checked out this question but as crt1.o
is not an object I compiled but part of a system package installed by Ubuntu, I think I am unable to re-compile it. But I might be wrong, I am not really familiar with gcc
.