我正在尝试将我自己的静态库链接到我的主程序中。我的包含头文件和库位于同一路径中。g++ 能够很好地链接主标题,但它无法找到我的库(ipc.a)。请让我知道我做错了什么。
我运行 make 时遇到的错误是:
# make
g++ -o esim esim.o -L /home/vint/HobbyProjects/esim/src/LIB/PLAT -lipc -Wall -g
/usr/bin/ld: cannot find -lipc
collect2: ld returned 1 exit status
Makefile在下面给出
INC_DIR = /home/vint/HobbyProjects/esim/src/LIB/PLAT
LIB_DIR = /home/vint/HobbyProjects/esim/src/LIB/PLAT
INCLUDES = -I $(INC_DIR)/
LIBS = -L$(LIB_DIR)/
LIBA = -lipc
CC = g++
DEBUG = -g
LFLAGS = -Wall $(DEBUG)
CFLAGS = -Wall -c
SOURCES = esim.cpp \
HEADERS = esim.h
OBJ = $(SOURCES:.cpp=.o)
EXE = esim
all: esim
$(EXE): $(OBJ)
$(CC) $(OBJ) $(INCLUDES) $(LIBA) -o $(EXE)
.cpp.o:
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
tar:
tar -czf $(EXE).tar.gz $(SOURCES) $(HEADERS) Makefile
clean:
rm -f $(OBJ)
rm -f $(EXE)