Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with linker error : error-cannot find -lgcc

this is my makefile:

task0 : main.o numbers.o add.o
        gcc -m32 -g -Wall -o task0 main.o numbers.o add.o

main.o : main.c
        gcc -g -Wall -m32 -ansi -c -o main.c
numbers.o : numbers.c
           gcc -g -Wall -m32 -ansi -c -o numbers.c
add.o: add.s
      nasm -g -f elf -w+all -o add.o add.s
clean : 
       rm -f *.o task0

and this is the terminal output:

gcc -m32 -g -Wall -o task0 main.o numbers.o add.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when      searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make: *** [task0] 1 הלקת

can someone explain me what is lgcc and how to fix that?

like image 486
kitsuneFox Avatar asked Mar 03 '14 21:03

kitsuneFox


People also ask

How do you fix a linker error?

You can fix the errors by including the source code file that contains the definitions as part of the compilation. Alternatively, you can pass . obj files or . lib files that contain the definitions to the linker.

What causes a linker error?

Linker errors occur when the linker is trying to put all the pieces of a program together to create an executable, and one or more pieces are missing. Typically, this can happen when an object file or libraries can't be found by the linker. Fixing linker errors can be tricky.

How do I fix the linker error C++ undefined symbol?

So when we try to assign it a value in the main function, the linker doesn't find the symbol and may result in an “unresolved external symbol” or “undefined reference”. The way to fix this error is to explicitly scope the variable using '::' outside the main before using it.

What causes linker errors C++?

Linker Errors: These error occurs when after compilation we link the different object files with main's object using Ctrl+F9 key(RUN). These are errors generated when the executable of the program cannot be generated. This may be due to wrong function prototyping, incorrect header files.


1 Answers

(Answered in a comment. See Question with no answers, but issue solved in the comments (or extended in chat) )

@Basil Starynkevitch wrote:

You should install the gcc-multilib package

@Jekyll wrote:

https://askubuntu.com/questions/250910/cross-compilation-issues-with-gcc-g

like image 153
3 revs Avatar answered Oct 06 '22 01:10

3 revs