c++ - Makefile 说变量是空的,但它不是

标签 c++ makefile

我正在尝试创建包含以下内容的 makefile:

$(CXX)=g++
$(SRC)=../src
$(INCL)=../include
all: cpu ram temperature swap statusshooter
    $(CXX) main.cpp cpu.o ram.o temperature.o swap.o statusshooter.o -o main.o -I$(INCL) -Ofast -Wall -lyaml-cpp -lglog -lpqxx -lpq
cpu:
    $(CXX) -c $(SRC)/CCpu.cpp -o cpu.o -Ofast -Wall 
ram:
    $(CXX) -c $(SRC)/CRam.cpp -o ram.o -Ofast -Wall 
temperature:
    $(CXX) -c $(SRC)/CTemperature.cpp -o temperature.o -Ofast -Wall
swap:
    $(CXX) -c $(SRC)/CSwap.cpp -o swap.o -Ofast -Wall  
statusshooter:
    $(CXX) -c $(SRC)/CStatusShooter.cpp -o statusshooter.o -Ofast -Wall  

使用以下命令执行该 makefile: make CXX=g++-4.7 抛出以下错误:

makefile:2: *** empty variable name.  Stop.

如何解决?

最佳答案

语法 $(CXX) 用于评估 make 变量,而不是分配给它。你要

CXX  = g++
SRC  = ../src
INCL = ../include

[...]

关于c++ - Makefile 说变量是空的,但它不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28768425/

相关文章:

c++ - 是否可以在 constexpr 函数中执行 I/O

c++ 17使用wav header 验证wav文件大小

c++ - 在 Eclipse 中突出显示 makefile

c - makefile 在 Windows 上适用于 cygwin,但不适用于 ubuntu

makefile - makefile 符号 $@ 和 $< 是什么意思?

c++ - 更多线程,更好的性能?

c++ - 在我的 Mac 上编译时,当我使用 "gcc"编译但不使用 clang++ 时出现此错误

c++ - 在完美转发函数中公开参数类型,避免代码重复

linux - 换了一个不正确的时钟。现在 code::blocks 拒绝构建 "all is up to date"

android - AOSP 构建 - 从 eng 切换到 user 或 userdebug 时,不再创建数据目录