【发布时间】:2012-03-09 16:13:21
【问题描述】:
我有简单的文件: 你好.h,你好.cpp
我创建了一个 makefile 来生成一个静态库 (libhello.a) 但我收到错误消息,我做错了什么?
我的代码是:
CC = g++
CFLAGS = -Wall -g
utilObjs = hello.o
libhello.a: $(utilObjs)
ar rc $@ $(utilObjs)
ranlib $@
hello: hello.o libhello.a
$(CC) $(CFLAGS) hello.o -L ./ -lutil -o $@
hello.o: hello.cpp hello.h
$(CC) $(CFLAGS) -c $>
clean:
rm -rf *.o libhello.a hello
all: hello
.PHONY: all clean
错误信息: g++:致命错误:没有输入文件 编译终止
【问题讨论】:
-
默认的 GNU make 规则(您可以使用
make -p获取它们)已经有编译 C++ 的规则,使用CXX而不是CC等。你应该使用remake帮助调试您的Makefile
标签: c++ linux makefile static-libraries