简体   繁体   中英

"cannot find -lc" Compiling via linux terminal

I make a premise: I'm a "newborn" in the Linux world, I have very little experience. I decided to switch to this operating system after studying it in a university course and I fell in love with it. Having said that, let me tell you my problem... I installed Linux Mint 21.1 initially in dual-boot with a fairly small partition size. To extend the partition I thought of reinstalling it from 0 thus avoiding some problems that were appearing. For university reasons I find myself programming and compiling from a terminal. At the first installation of Linux I managed to install everything necessary and to solve the various problems that arose. On reinstallation, when I try to compile a file from the terminal, I get the following message:

gcc -c procedure.c
gcc -c semafori.c
gcc -c prodcons_singolo_buffer.c
gcc -o prodcons_singolo_buffer procedure.o semafori.o prodcons_singolo_buffer.o
/usr/bin/ld: impossibile trovare -lc: File o directory non esistente
collect2: error: ld returned 1 exit status
make: *** [Makefile:4: prodcons_singolo_buffer] Errore

In particular, the error Is:

usr/bin/ld: impossibile trovare -lc: File o directory non esistente

Unfortunately I can't find anything about it on the web. Thank you all for your availability and for any response.

EDIT: This is Makefile:

    all: prodcons_singolo_buffer

prodcons_singolo_buffer: procedure.o semafori.o prodcons_singolo_buffer.o
    gcc -o prodcons_singolo_buffer procedure.o semafori.o prodcons_singolo_buffer.o

prodcons_singolo_buffer.o: prodcons_singolo_buffer.c
    gcc -c prodcons_singolo_buffer.c

procedure.o: procedure.h procedure.c
    gcc -c procedure.c

semafori.o: semafori.c semafori.h
    gcc -c semafori.c

clean:
    rm -rf *.o
    rm -rf prodcons_singolo_buffer

I agree that your compiler/library install is borked.

Unrelated but here is how I would write your Makefile (untested). Let me know when you tried it out and I will delete this answer.

.PHONY: all clean

all: prodcons_singolo_buffer

prodcons_singolo_buffer: procedure.o semafori.o prodcons_singolo_buffer.o

procedure.o:  procedure.c procedure.h

semafori.o: semafori.c semafori.h

clean:
    rm -f prodcons_singolo_buffer *.o

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM