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?
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.
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.
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.
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.
(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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With