0

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.

Gábor Héja
  • 458
  • 7
  • 17
  • 2
    It looks like you have brought object files compiled for a different OS and/or architecture, or are otherwise trying to link native and cross-compiled objects. Please show in full all of the commands you ran in your build process. – n. m. could be an AI Feb 21 '19 at 17:11
  • Possible duplicate of [Undefined reference to mempcy@GLIBC\_2.14 when compiling on Linux](https://stackoverflow.com/q/12286460/608639) – jww Feb 22 '19 at 01:05
  • @n.m., Is the crt1.o related to the project? It seems to be a file installed by a system package. Does the way crt1.o works depend on the project I try to compile? – Gábor Héja Feb 22 '19 at 09:53
  • @jww, I think this is a separate problem as crt1.o seems to be originating from a system package, also I cannot use that solution (I am not able to compile glibc here). – Gábor Héja Feb 22 '19 at 09:54
  • I think you need to remove all packages that have *cross* in their name from your system, and install normal gcc via `apt-get install build-essential`. – n. m. could be an AI Feb 23 '19 at 19:43
  • I could not solve this problem. As a workaround I created a chrooted environment using a different release for the application, it works iniside that. – Gábor Héja Mar 20 '19 at 09:47

0 Answers0