本文介绍了无法在配方内分配变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何进行这项工作?错误显示为"make:somevariable:找不到命令"

How do I make this work? It errors out with "make: somevariable: Command not found"

sometarget:
    somevariable = somevalue

完整示例:

CXXFLAGS = -I/usr/include/test -shared -fPIC

OBJ = main.o Server.o

blabla : $(OBJ)
ifeq ($(argsexec),true)
    # Creates an executable
    CXXFLAGS = -I/usr/include/test
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS)
else
    # Creates a library
    DESTDIR = /home/pc
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS)
    ./bn.sh
endif

推荐答案

我找到了使用 eval函数:

I found a solution using the eval function:

$(eval variablename=whatever)

这有效:)

(尽管我现在可以尝试找到一个更简单的构建系统;))

(although I may now try to find an easier build system ;))

感谢大家的阅读,当然也感谢@eriktous的写作!

Thanks everyone for reading and also of course @eriktous for writing!

这篇关于无法在配方内分配变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 22:50