0

我还是很陌生。我正在尝试编译一个项目,其中 maketest.cpp 和 maketest.hpp 依赖于Users/wen/Projects/maketestMakefile 本身。.cc问题是,我还想.hhUsers/wen/Projects/include/bigint.

# Macros

INCLUDE = -I/Users/wen/Projects/include/bigint
LIBS =

CC = g++
override FLAGS += -O2

HEADERS= $(wildcard *.hpp) $(wildcard Users/wen/Projects/include/bigint/*.hh) 

# EXE Name
INSTALL = maketest

CC_FILES = %.cpp Users/wen/Projects/include/bigint/%.cc
OBJ_FILES = maketest.o $(wildcard Users/wen/Projects/include/bigint/*.o)

# Rules

$(INSTALL): $(OBJ_FILES)
    $(CC) $(FLAGS) $^ -o $@ $(LIBS)

%.o: $(CC_FILES) $(HEADERS)
    $(CC) $(FLAGS) $(INCLUDE) -c $< -o $@

# Installation types

install: $(INSTALL)

release:
    @echo "Re-run with parameter:"
    @echo "FLAGS=-D_RELEASE"

debug:
    @echo "Re-run with parameter:"
    @echo "FLAGS=-D_DEBUG"

# Cleaning up

clean:
    rm -f $(OBJ_FILES) $(INSTALL)

该代码编译 maketest.cpp 并链接它,但不是 bigint。

构建和链接文件的正确方法是Users/wen/Projects/include/bigint什么?非常感谢!

4

1 回答 1

1

最后我想通了,谢谢Jay。问题是我忘记了前面的斜杠Users/wen/Projects/include/bigint,所以它不是从根目录搜索,而是从项目文件夹搜索。现在它起作用了!

尝试在 OBJ_FILES 中显式指定来自 bigint 的文件之一(可能是“bigint.o”?)。我不认为你的通配符得到你想要的。

于 2012-12-20T01:31:21.187 回答