/ usr / bin / ld:找不到-lgd

时间:2014-04-15 18:22:15

标签: c++ linux makefile

所以我尝试使用 make -f Makefile 编译程序,但是我收到此错误 / usr / bin / ld:找不到-lgd

root@kevin-VirtualBox://home/kevin/Desktop/makef# make -f Makefile
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld: cannot find -lgd
collect2: ld returned 1 exit status
make: *** [main] Error 1
root@kevin-VirtualBox://home/kevin/Desktop/makef# 

生成文件:

IDIR =./
CC=gcc
CFLAGS=-I$(IDIR)

ODIR=obj
LDIR =./

LIBS=-lgd -lrt

_DEPS = main.h Makefile
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))

_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))


$(ODIR)/%.o: %.c $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

main: $(OBJ)
    gcc -o $@ $^ $(CFLAGS) $(LIBS)

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ 
替换后的

(libgd.a libgd.la libgd.so libgd.so.2 libgd.so.2.0.0)我收到此错误:

root@kevin-VirtualBox://home/kevin/Desktop/makef# make -f Makefilegcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/libgd.a when searching for -lgd
/usr/bin/ld: cannot find -lgd
collect2: ld returned 1 exit status
make: *** [main] Error 1

1 个答案:

答案 0 :(得分:2)

您应该安装包libgd-dev(或libgd-devel,具体取决于操作系统/分发)。链接所必需的部分是符号链接/usr/lib/libgd.so(通常指向/usr/lib/lib/libgd.so.2