我正在尝试用 g++ 构建一个程序,但我得到了“未定义的引用”。
文件夹结构:
Makefile
libs/
libcrypotpp.a
libz.a
sources/
here are the sources and headers
out/
objfiles/
Makefile 如下所示:
#makefile for program
#needs libz.a and libcryptopp.a
CC = g++
SOURCES = sources/*.cpp
LIBS = -lcryptopp -lz -pthread
LIBPATH = libs/
OBJPATH = objfiles/
OUTPUT = out/
OBJS = *.o
HEADERPATHS = -Isources -Isources/cryptopp
all:
echo "Program"
echo "------------------"
ifneq ("$(wildcard libs/libz.a)", "")
echo "ZLIB found!"
ifneq ("$(wildcard libs/libcryptopp.a)", "")
echo "Cryptopp found!" #all librarys found
$(CC) $(HEADERPATHS) -L$(LIBPATH) $(LIBS) $(SOURCES)
mv *.o $(OBJPATH)
else
echo "error: Cryptopp(libs/libcryptopp.a) was not found!"
endif
else ifneq ("$(wildcard libs/libcryptopp.a)", "")
echo "Cryptopp found!"
echo "error: ZLIB(libs/libz.a) was not found!"
else
echo "error: ZLIB(libs/libz.a) was not found!"
echo "error: Cryptopp(libs/libcryptopp.a) was not found!"
endif
.SILENT: all
g++ 编译,但随后输出未定义的引用:
为什么会失败?