Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何显示特定gcc Makefile目标变量的值?_C++_Linux_Ubuntu_Gcc_Makefile - Fatal编程技术网

C++ 如何显示特定gcc Makefile目标变量的值?

C++ 如何显示特定gcc Makefile目标变量的值?,c++,linux,ubuntu,gcc,makefile,C++,Linux,Ubuntu,Gcc,Makefile,我正在尝试调试来自ChatScript开源聊天机器人项目的gcc Makefile中的一个问题: 以下是我的相关版本号: Ubuntu 14.04 make version 3.81 gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 我似乎无法在当前工作目录旁边的另一个目录中找到源文件。如果我将源文件移动到当前目录,它工作正常,但如果我将文件放回旧目录,它会抱怨找不到: make: *** No rule to make target `pri

我正在尝试调试来自ChatScript开源聊天机器人项目的gcc Makefile中的一个问题:

以下是我的相关版本号:

Ubuntu 14.04
make version 3.81
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
我似乎无法在当前工作目录旁边的另一个目录中找到源文件。如果我将源文件移动到当前目录,它工作正常,但如果我将文件放回旧目录,它会抱怨找不到:

make: *** No rule to make target `privatesrc.cpp', needed by `all'.  Stop.
执行make时我所在的当前目录是SRC,Makefile所在的目录。privatesrc.cpp位于同级目录中,应该可以通过以下相对路径从SRC访问该目录:

../privatecode/privatesrc.cpp

要调试这个问题,我希望看到make目标的每个变量的文件是什么。我使用这两个SO帖子尝试转储这些值:

吉姆·尼斯比的回答。以及:

这是公认的答案

我创建了一个名为server_dry_run的新make target,以便于:

server_dry_run: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server_dry_run: PGLOAD= -pthread
server_dry_run: INCLUDEDIRS=-Ievserver
server_dry_run: all
server_dry_run: EXECUTABLE=../BINARIES/ChatScript
server_dry_run: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 
# Uncomment this line if you want to filter out variables already defined.
# VARS_OLD := $(.VARIABLES)
CUR-DIR := $(shell pwd)
LOG-DIR := $(CUR-DIR)/make-logs
$(info INCLUDEDIRS="$(INCLUDEDIRS)")
$(foreach v,$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)),$(info $(v) = $($(v))))
但是,INCLUDEDIRS始终显示为空:

INCLUDEDIRS=""
如何查看INCLUDEDIRS的值以便解决此问题

下面是我的Makefile的全部内容。注意,我确实尝试删除了在分配给INCLUDEDIRS的值周围添加的引号,但没有帮助。另一位数据。如果执行“make clean”,则会出现错误“rm:cannot remove`../':Is a directory”,这似乎表明可执行目标变量可能不正确

生成文件:

debugserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1 -DDEBUG
debugserver: PGLOAD= -pthread
debugserver: INCLUDEDIRS="-Ievserver -I../privatecode"
debugserver: all
debugserver: EXECUTABLE=../BINARIES/ChatScriptDebug
debugserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -g

debugpgserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1  -DDEBUG
debugpgserver: PGLOAD= -lpq -pthread
debugpgserver: INCLUDEDIRS="-Ievserver -I../privatecode"
debugpgserver: all
debugpgserver: EXECUTABLE=../BINARIES/ChatScriptpgDebug
debugpgserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -g

server: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server: PGLOAD= -pthread
server: INCLUDEDIRS="-Ievserver -I../privatecode"
server: all
server: EXECUTABLE=../BINARIES/ChatScript
server: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

standalone: DEFINES+= -DPRIVATE_CODE  -DDISCARDSERVER=1 -DDISCARDDATABASE=1 
standalone: PGLOAD= -pthread
standalone: INCLUDEDIRS="-Ievserver -I../privatecode"
standalone: all
standalone: EXECUTABLE=../BINARIES/ChatScript
standalone: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

pgserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 
pgserver: PGLOAD= -lpq -pthread
pgserver: all
pgserver: EXECUTABLE=../BINARIES/ChatScriptpg
pgserver: INCLUDEDIRS="-Ievserver -Ipostgres -I../privatecode"
pgserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 


mongoserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 
mongoserver: PGLOAD= -lpq -pthread
mongoserver: all
mongoserver: EXECUTABLE=../BINARIES/ChatScriptmongo
mongoserver: INCLUDEDIRS="-Ievserver -I../privatecode"
mongoserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

server_dry_run: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server_dry_run: PGLOAD= -pthread
server_dry_run: INCLUDEDIRS=-Ievserver -I../privatecode
server_dry_run: all
server_dry_run: EXECUTABLE=../BINARIES/ChatScript
server_dry_run: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 
# Uncomment this line if you want to filter out variables already defined.
# VARS_OLD := $(.VARIABLES)
CUR-DIR := $(shell pwd)
LOG-DIR := $(CUR-DIR)/make-logs
$(info INCLUDEDIRS="$(INCLUDEDIRS)")
$(foreach v,$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)),$(info $(v) = $($(v))))

UNAME := $(shell uname)

CC=g++

ifeq ($(UNAME), Linux)
$(info ************ LINUX VERSION ************)
LDFLAGS= -lrt -lcurl --verbose $(PGLOAD) 
endif

ifeq ($(UNAME), Darwin)
$(info ************ MAC VERSION ************)
LDFLAGS=-mmacosx-version-min=10.7 $(PGLOAD)  
CFLAGS=-mmacosx-version-min=10.7 -c -Wall  -funsigned-char -Wno-write-strings -Wno-char-subscripts 
endif

SOURCES=constructCode.cpp evserver.cpp csocket.cpp cs_ev.c dictionarySystem.cpp englishTagger.cpp factSystem.cpp  functionExecute.cpp english.cpp infer.cpp javascript.cpp jsmn.cpp markSystem.cpp os.cpp outputSystem.cpp patternSystem.cpp privatesrc.cpp scriptCompile.cpp spellcheck.cpp secure.cpp systemVariables.cpp tagger.cpp testing.cpp textUtilities.cpp tokenSystem.cpp topicSystem.cpp userCache.cpp userSystem.cpp variableSystem.cpp mainSystem.cpp 
OBJECTS=$(SOURCES:.cpp=.o)

all: $(SOURCES) binary

clean:
    -rm -f $(EXECUTABLE)
    -rm -f ../$(EXECUTABLE)
    -rm -f *.o

binary: $(OBJECTS)
    $(CC) $(OBJECTS) $(LDFLAGS) $(DEFINES) $(INCLUDEDIRS) -o $(EXECUTABLE)

.cpp.o:
    $(CC) $(CFLAGS) $(DEFINES) $(INCLUDEDIRS) $< -o $@
debugserver:DEFINES+=-DPRIVATE\u code-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1-DDISCARDDATABASE=1-DDEBUG
debugserver:PGLOAD=-pthread
debugserver:INCLUDEDIRS=“-Ievserver-I../privatecode”
调试服务器:全部
debugserver:EXECUTABLE=../BINARIES/ChatScriptDebug
debugserver:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno strict aliasing-g
debugpgserver:DEFINES+=-DPRIVATE\u CODE-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1-DDEBUG
debugpgserver:PGLOAD=-lpq-pthread
debugpgserver:INCLUDEDIRS=“-Ievserver-I../privatecode”
调试服务器:全部
debugpgserver:EXECUTABLE=../BINARIES/ChatScriptpgDebug
debugpgserver:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno strict aliasing-g
服务器:DEFINES+=-DPRIVATE\u CODE-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1-DDISCARDDATABASE=1
服务器:PGLOAD=-pthread
服务器:INCLUDEDIRS=“-Ievserver-I../privatecode”
服务器:全部
服务器:可执行文件=../BINARIES/ChatScript
服务器:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno严格别名
独立:定义+=-Dpivate\u代码-DDISCARDSERVER=1-DDISCARDDATABASE=1
独立:PGLOAD=-pthread
独立:INCLUDEDIRS=“-Ievserver-I../privatecode”
单机版:全部
独立:可执行文件=../BINARIES/ChatScript
独立:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno严格别名
pgserver:DEFINES+=-DPRIVATE\u CODE-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1
pgserver:PGLOAD=-lpq-pthread
pgserver:所有
pgserver:EXECUTABLE=../BINARIES/ChatScriptpg
pgserver:INCLUDEDIRS=“-Ievserver-Ipostgres-I../privatecode”
pgserver:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno严格别名
mongoserver:DEFINES+=-DPRIVATE\u CODE-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1
mongoserver:PGLOAD=-lpq-pthread
mongoserver:所有
mongoserver:EXECUTABLE=../BINARIES/ChatScriptmongo
mongoserver:INCLUDEDIRS=“-Ievserver-I../privatecode”
mongoserver:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno严格别名
server\u dry\u run:DEFINES+=-DPRIVATE\u CODE-DLOCKUSERFILE=1-DEVSERVER=1-DEVSERVER\u FORK=1-DDISCARDDATABASE=1
服务器运行:PGLOAD=-pthread
服务器运行:INCLUDEDIRS=-Ievserver-I../privatecode
服务器\u干燥\u运行:全部
服务器\u dry\u运行:可执行文件=../BINARIES/ChatScript
server\u dry\u run:CFLAGS=-c-Wall-funsigned char-Wno write strings-Wno char subscripts-Wno严格别名
#如果要过滤掉已定义的变量,请取消对此行的注释。
#VARS_OLD:=$(.VARIABLES)
CUR-DIR:=$(外壳pwd)
LOG-DIR:=$(CUR-DIR)/生成日志
$(信息INCLUDEDIRS=“$(INCLUDEDIRS)”)
$(foreach v,$(过滤掉$(VARS_OLD)VARS_OLD,$(.VARIABLES)),$(info$(v)=$($(v)))
UNAME:=$(shell UNAME)
CC=g++
ifeq($(UNAME),Linux)
$(信息*************LINUX版本***********)
LDFLAGS=-lrt-lcurl--verbose$(PGLOAD)
恩迪夫
ifeq($(UNAME),达尔文)
$(信息*************MAC版本**************)
LDFLAGS=-mmacosx版本最小值=10.7$(PGLOAD)
CFLAGS=-mmacosx version min=10.7-c-Wall-funsigned char-Wno write strings-Wno char subscripts
恩迪夫
SOURCES=constructCode.cpp evserver.cpp csocket.cpp cs_ev.c dictionarySystem.cpp englishTagger.cpp factSystem.cpp functionExecute.cpp english.cpp expert.cpp javascript.cpp jsmn.cpp markSystem.cpp os.cpp outputSystem.cpp patternSystem.cpp privatesrc.cpp scriptCompile.cpp拼写检查.cpp secure.cpp systemVariables.cpp tagger.cpp testing.cpptextUtilities.cpp tokenSystem.cpp topicSystem.cpp userCache.cpp userSystem.cpp variableSystem.cpp mainSystem.cpp
对象=$(源:.cpp=.o)
全部:$(源)二进制
清洁:
-rm-f$(可执行文件)
-rm-f../$(可执行文件)
-rm-f*.o
二进制:$(对象)
$(CC)$(对象)$(LDFLAGS)$(定义)$(INCLUDEDIRS)-o$(可执行)
.cpp.o:
$(CC)$(CFLAGS)$(定义)$(包括IRS)$<-o$@

info
作为make对文件执行的第一次传递的一部分执行,此时
INCLUDEDIRS
为空,仅在make开始通过目标解析时设置。另外,据我所知,make无法知道这些源文件可以在
。/privatecode
中找到,您需要为此指定
vpath
s。为什么源文件是
all
的目标,这也没什么意义。@user657267 1)谢谢