Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker command failed with exit code 1 - ld: Undefined symbols [duplicate]

Tags:

c

when trying to make the executable file in C, this error appears. I don't know what I did wrong, what can I do to fix this?

Error code

main.c

bib.h

print.c

I ran this two commands, but same error:

clang main.c -o main   OR   clang ./main.c -o main

gcc -Wall -o main ./main.c
like image 506
Felix H Avatar asked Jun 07 '26 11:06

Felix H


1 Answers

You forgot to include the print.c file in your clang command. You must do this otherwise the compiler has no idea where the code to the void print(); function actually lives. You're essentially telling it that it exists but not telling it what it does so it throws.

clang main.c print.c -o main

like image 132
Large0range Avatar answered Jun 10 '26 03:06

Large0range



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!