i have this xml, and i dont know how to get the names of the children given a name also.
<return_message>
<status>True</status>
<return_value>
<folder_tree_node>
<folder>
<name>CR1</name>
<path>Root\Test Sets\WBTS SW CI\CR1</path>
</folder>
<folder_tree_node>
<folder>
<name>FB14.07</name>
<path>Root\Test Sets\WBTS SW CI\CR1\FB14.07</path>
</folder>
<folder_tree_node>
<folder>
<name>CW27_1</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1</path>
</folder>
<folder_tree_node>
<folder>
<name>Antenna Line Mng</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\ Line Mng</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>BTS start up & Rec</name>Antenna
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\BTS start up & Rec</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>CC & SM</name>
<path>Root\Test Sets\WBTS SW CI\CR1\FB14.07\CW27_1\CC
& SM</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Frequency Variants</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Frequency Variants</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>NetAct Interoperability</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\NetAct Interoperability</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Pre-Stability</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Pre-Stability</path>
</folder>
</folder_tree_node>w
<folder_tree_node>
<folder>
<name>RAB</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\RAB</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Test & Measurements</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Test & Measurements</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Tracebility</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Tracebility</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Transmission</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Transmission</path>
</folder>
</folder_tree_node>
</folder_tree_node>
I want to get all the names of the children of a given node. I.E given CW27_1, xpath would return the ff. Antenna Line Mng, BTS startup, CC& amp . What xpath should i have to do this?
try
//folder_tree_node/folder/name[.='CW27_1']/../../folder_tree_node/descendant::name
it will get the following:
<name>Antenna Line Mng</name>
<name>BTS start up & Rec</name>
<name>CC & SM</name>
<name>Frequency Variants</name>
<name>NetAct Interoperability</name>
<name>Pre-Stability</name>
<name>RAB</name>
<name>Test & Measurements</name>
<name>Tracebility</name>
<name>Transmission</name>
Related
i am working on a chess engine and recently decided to rewrite our makefile. I have decided to go for a recursive makefile which features a set of options to compile with:
NAMING ?= 1
STATIC ?= 0
NATIVE ?= 0
DETECT ?= 1
PGO ?= 0
DEBUG ?= 0
LTO ?= 0
PEXT ?= 0
Based on the flags above, I generate the FLAGS to build my program. The main target of my makefile is called build. My makefile uses the flags above and generates all the options. Theoretically the makefile works fine if i call it like make build PGO=1 NATIVE=1 .... Now this is the behaviour I wanted to have. Furthermore I had the idea to do a recursive makefile which predefines a few of those options like:
native:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=0 LTO=1 DETECT=1 NAMING=$(NAMING) STATIC=$(STATIC) EXE_NAME=$(EXE_NAME)
pgo:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=1 LTO=1 DETECT=1 NAMING=$(NAMING) STATIC=$(STATIC) EXE_NAME=$(EXE_NAME)
The problem is that I am unable to overwrite those specified variables in the recursive makefile. Lets say I call make pgo, it goes into recursive make and calls
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=1 LTO=1 DETECT=1 NAMING=$(NAMING) STATIC=$(STATIC) EXE_NAME=$(EXE_NAME)
When i try to specify PGO := 0 in the makefile, it seems to have no impact on the PGO variable. It seems like I cannot overwrite it when called the way I do it. The complete makefile is the following:
_THIS := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
_ROOT := $(_THIS)/..
_SRC := $(_ROOT)/src_files
_BIN := $(_ROOT)/bin
_MAKE := $(MAKE) --no-print-directory -C $(_THIS) -e
# compiler and sources
CXX = g++
_LIBS_WL := -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
_LIBS := -pthread
_CXXSRCS := $(_SRC)/*.cpp
_CSRCS := $(_SRC)/syzygy/tbprobe.c
_SRCS := $(_CSRCS) $(_CXXSRCS)
# engine name and version
NAME = Koivisto
MINOR = 11
MAJOR = 8
MAKROS = -DMINOR_VERSION=$(MINOR) -DMAJOR_VERSION=$(MAJOR)
EXE_NAME = $(NAME)_$(MAJOR).$(MINOR)
EXE_DIR = $(_ROOT)/bin
EXE = $(EXE_DIR)/$(EXE_NAME)
EVALFILE = $(_ROOT)/networks/default.net
EXE_INFO =
# compilation flags
FLAGS = -std=c++17 -Wall -Wextra -Wshadow -DEVALFILE=\"$(EVALFILE)\"
MARCH_FLAG = -march=native
PGO_PRE_FLAGS = -fprofile-generate -lgcov
PGO_POST_FLAGS = -fprofile-use -fno-peel-loops -fno-tracer
# ---------------------------------------------------------------------------------------------------------------------
# COMPILATION OPTIONS AND NAME ADJUSTMENT
# ---------------------------------------------------------------------------------------------------------------------
# options
NAMING ?= 1
STATIC ?= 0
NATIVE ?= 0
DETECT ?= 1
PGO ?= 0
DEBUG ?= 0
LTO ?= 0
PEXT ?= 0
# vector instructions
AVX512 ?= 0
AVX2 ?= $(AVX512)
AVX ?= $(AVX2)
POPCNT ?= $(AVX)
SSE42 ?= $(POPCNT)
SSE41 ?= $(SSE42)
SSE3 ?= $(SSE41)
SSE2 ?= $(SSE3)
SSE ?= $(SSE2)
# adjust the exe name as well as the FLAGS
ifeq ($(PGO),1)
EXE_INFO := $(EXE_INFO)-pgo
endif
ifeq ($(DEBUG),1)
EXE_INFO := $(EXE_INFO)-debug
else
FLAGS += -DNDEBUG -O3
endif
ifeq ($(PEXT),1)
EXE_INFO := $(EXE_INFO)-pext
FLAGS += -DUSE_PEXT -mbmi2
endif
ifeq ($(LTO),1)
FLAGS += -flto
endif
ifeq ($(STATIC),1)
FLAGS += -static -static-libgcc -static-libstdc++
endif
# toggle avx options based on the highest one
ifeq ($(AVX512),1)
FLAGS += -mavx512f -mavx512bw -mavx512dq
endif
ifeq ($(AVX2),1)
FLAGS += -mavx2
endif
ifeq ($(AVX),1)
FLAGS += -mavx
endif
ifeq ($(POPCNT),1)
FLAGS += -DUSE_POPCNT -mpopcnt
endif
ifeq ($(SSE42),1)
FLAGS += -msse4.2
endif
ifeq ($(SSE41),1)
FLAGS += -msse4.1
endif
ifeq ($(SSE3),1)
FLAGS += -msse3
endif
ifeq ($(SSE2),1)
FLAGS += -msse2
endif
ifeq ($(SSE),1)
FLAGS += -msse
endif
# set name based on highest vector extension
ifeq ($(AVX512),1)
EXE_INFO := $(EXE_INFO)-avx512
else ifeq ($(AVX2),1)
EXE_INFO := $(EXE_INFO)-avx2
else ifeq ($(AVX),1)
EXE_INFO := $(EXE_INFO)-avx
else ifeq ($(POPCNT),1)
EXE_INFO := $(EXE_INFO)-popcnt
else ifeq ($(SSE42),1)
EXE_INFO := $(EXE_INFO)-sse42
else ifeq ($(SSE41),1)
EXE_INFO := $(EXE_INFO)-sse41
else ifeq ($(SSE3),1)
EXE_INFO := $(EXE_INFO)-msse3
else ifeq ($(SSE2),1)
EXE_INFO := $(EXE_INFO)-sse2
else ifeq ($(SSE),1)
EXE_INFO := $(EXE_INFO)-sse
endif
# ---------------------------------------------------------------------------------------------------------------------
# HOST DETECTION AND NAME ADJUSTMENT IF NAMING IS ACTIVE
# ---------------------------------------------------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
PREFIX := windows
SUFFIX := .exe
_LIBS += $(_LIBS_WL)
else
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
PREFIX := linux
SUFFIX :=
_LIBS += $(_LIBS_WL)
else
ifeq ($(UNAME),Darwin)
PREFIX := darwin
SUFFIX :=
MARCH_FLAG := -mcpu=apple-a14
else
$(warning incompatible host, this might fail)
PREFIX := _
SUFFIX :=
endif
endif
endif
ifeq ($(NAMING),1)
EXE := $(EXE_DIR)/$(EXE_NAME)-$(PREFIX)$(EXE_INFO)$(SUFFIX)
endif
EXE_FULL := $(abspath $(EXE))
FLAGS += $(MARCH_FLAG)
# auto detect certain flags
ifeq ($(DETECT),1)
PROPS = $(shell echo | $(CC) $(MARCH_FLAG) -E -dM -)
ifneq ($(findstring __BMI2__, $(PROPS)),)
ifeq ($(findstring __znver1, $(PROPS)),)
ifeq ($(findstring __znver2, $(PROPS)),)
FLAGS += $(PEXTFLAGS)
endif
endif
endif
endif
# ---------------------------------------------------------------------------------------------------------------------
# RULES
# ---------------------------------------------------------------------------------------------------------------------
ifeq ($(UNAME),Darwin)
openbench:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=0 LTO=1 DETECT=1 EVALFILE=$(EVALFILE) NAMING=0 EXE=$(EXE)
else
openbench:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=1 LTO=1 DETECT=1 EVALFILE=$(EVALFILE) NAMING=0 EXE=$(EXE)
endif
native:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=0 LTO=1 DETECT=1 NAMING=$(NAMING) STATIC=$(STATIC) EXE_NAME=$(EXE_NAME)
pgo:
$(_MAKE) build DEBUG=0 NATIVE=1 PGO=1 LTO=1 DETECT=1 NAMING=$(NAMING) STATIC=$(STATIC) EXE_NAME=$(EXE_NAME)
overview:
$(info NAME : $(NAME))
$(info EXE : $(EXE))
$(info FULL NAME : $(EXE_FULL))
$(info NAMING : $(NAMING))
$(info FLAGS : $(FLAGS))
$(info NATIVE : $(NATIVE))
$(info STATIC : $(STATIC))
$(info PEXT : $(PEXT))
$(info PGO : $(PGO))
$(info DEBUG : $(DEBUG))
$(info AVX512 : $(AVX512))
$(info AVX2 : $(AVX2))
$(info AVX : $(AVX))
$(info POPCNT : $(POPCNT))
$(info SSE42 : $(SSE42))
$(info SSE41 : $(SSE41))
$(info SSE3 : $(SSE3))
$(info SSE2 : $(SSE2))
$(info SSE : $(SSE))
build: updateNetwork overview
mkdir -p $(EXE_DIR)
ifeq ($(PGO),1)
$(CXX) $(PGO_PRE_FLAGS) $(FLAGS) $(_SRCS) $(MAKROS) $(_LIBS) -o $(EXE)
$(EXE_FULL) bench
$(CXX) $(PGO_POST_FLAGS) $(FLAGS) $(_SRCS) $(MAKROS) $(_LIBS) -o $(EXE)
#rm -f *.gcda
else
$(CXX) $(FLAGS) $(_SRCS) $(MAKROS) $(_LIBS) -o $(EXE)
endif
release:
#$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 AVX512=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 AVX2=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 POPCNT=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE42=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE41=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE3=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE2=1
$(_MAKE) build DEBUG=0 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE=1
#$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 AVX512=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 AVX2=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 POPCNT=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE42=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE41=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE3=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE2=1
$(_MAKE) build DEBUG=0 PEXT=1 PGO=1 LTO=1 DETECT=0 NAMING=1 STATIC=1 SSE=1
# update the network
updateNetwork:
ifeq ($(EVALFILE),$(_ROOT)/networks/default.net)
git -C .. submodule update --init
endif
Does anyone know how I can overwrite variables in recursive makefiles? I am very happy for any help!
From the manual:
If a variable has been set with a command argument, then ordinary
assignments in the makefile are ignored. If you want to set the
variable in the makefile even though it was set with a command
argument, you can use an override directive...
Like so:
override PGO := 0
i'm doing a static library in asm and i'm trying to use its fonctions after in a c main.
I don't understand why, during the make test rule, the linkage doesnt work since i checked the library dir with -L. and the include dir with -I ./include, as well as the lib itself with -static and -lasm
What can i change ?
Here is my Makefile :
NAME = libasm.a
SRC = ft_write.s \
ft_read.s \
ft_strcmp.s \
ft_strcpy.s \
ft_strdup.s \
ft_strlen.s
SRC_BONUS = ft_atoi_base.s \
ft_list_push_front.s \
ft_list_size.s \
ft_list_sort.s \
ft_list_remove_if.s
SRC_DIR = ./srcs
CC = clang
CFLAGS = -v -L. -I$(INCLUDE) -static -Wall -Wextra -Werror -lasm
NASM = nasm
NASMFLAGS = -f elf64
INCLUDE = ./include
OBJ_DIR = ./objs
OBJ = $(patsubst %.s, ${OBJ_DIR}/%.o, ${SRC})
OBJ_BONUS = $(OBJ) $(patsubst %.s, ${OBJ_DIR}/%.o, ${SRC_BONUS})
BIN = test
all : $(NAME)
$(NAME) : $(OBJ)
ar rcs $# $^
ranlib $(NAME)
#echo "$(NAME) has been created"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
mkdir -p $(OBJ_DIR)
#echo "\033[0;32mGenerating binary..."
$(NASM) $(NASMFLAGS) $< -o $#
#echo "\033[0m"
test : main.c $(NAME)
$(CC) $< $(CFLAGS) -o $(BIN)
./$(BIN)
bonus : $(OBJ_BONUS)
ar rcs $(NAME) $^
ranlib $(NAME)
#echo "$(NAME) with bonus has been created"
clean :
rm -f $(OBJ_BONUS)
fclean : clean
rm -f $(NAME)
rm -f $(BIN)
and the trace : the problem is the undefined reference (référence indéfinie)
clang main.c -v -g -L. -I./include -static -Wall -Wextra -Werror -lasm -o test
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;#m64
Selected multilib: .;#m64
"/usr/lib/llvm-6.0/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -static-define -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-6.0/lib/clang/6.0.0 -I ./include -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -Werror -fdebug-compilation-dir /home/salty/Documents/libasm -ferror-limit 19 -fmessage-length 106 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-559408.o -x c main.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
./include
/usr/local/include
/usr/lib/llvm-6.0/lib/clang/6.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -z relro --hash-style=gnu -m elf_x86_64 -static -o test /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/crtbeginT.o -L. -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../.. -L/usr/lib/llvm-6.0/bin/../lib -L/lib -L/usr/lib /tmp/main-559408.o -lasm --start-group -lgcc -lgcc_eh -lc --end-group /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crtn.o
/tmp/main-559408.o : Dans la fonction « check_strlen » :
libasm/main.c:13 : référence indéfinie vers « ft_strlen »
/tmp/main-559408.o : Dans la fonction « check_strcmp » :
libasm/main.c:22 : référence indéfinie vers « ft_strcmp »
/tmp/main-559408.o : Dans la fonction « check_strdup » :
libasm/main.c:33 : référence indéfinie vers « ft_strdup »
/tmp/main-559408.o : Dans la fonction « strdup_test » :
libasm/main.c:42 : référence indéfinie vers « ft_strdup »
/tmp/main-559408.o : Dans la fonction « check_strcpy » :
libasm/main.c:61 : référence indéfinie vers « ft_strcpy »
libasm/main.c:64 : référence indéfinie vers « ft_strcpy »
/tmp/main-559408.o : Dans la fonction « strcpy_test » :
libasm/main.c:75 : référence indéfinie vers « ft_strcpy »
libasm/main.c:94 : référence indéfinie vers « ft_strcpy »
libasm/main.c:98 : référence indéfinie vers « ft_strcpy »
/tmp/main-559408.o:/home/salty/Documents/libasm/main.c:102 : encore plus de références indéfinies suivent vers « ft_strcpy »
/tmp/main-559408.o : Dans la fonction « list_size_test » :
libasm/main.c:176 : référence indéfinie vers « ft_list_size »
/tmp/main-559408.o : Dans la fonction « list_sort_test » :
libasm/main.c:242 : référence indéfinie vers « ft_list_sort »
/tmp/main-559408.o : Dans la fonction « list_push_front_test » :
libasm/main.c:264 : référence indéfinie vers « ft_list_push_front »
/tmp/main-559408.o : Dans la fonction « list_remove_if_test » :
libasm/main.c:287 : référence indéfinie vers « ft_list_remove_if »
/tmp/main-559408.o : Dans la fonction « atoi_base_test » :
libasm/main.c:297 : référence indéfinie vers « ft_atoi_base »
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:61: recipe for target 'test' failed
make: *** [test] Error 1
And also the dir tree:
./
├── include
│ └── libasm.h
├── libasm.a
├── main.c
├── Makefile
├── objs
│ ├── ft_atoi_base.o
│ ├── ft_list_push_front.o
│ ├── ft_list_remove_if.o
│ ├── ft_list_size.o
│ ├── ft_list_sort.o
│ ├── ft_read.o
│ ├── ft_strcmp.o
│ ├── ft_strcpy.o
│ ├── ft_strdup.o
│ ├── ft_strlen.o
│ └── ft_write.o
└── srcs
├── ft_atoi_base.s
├── ft_list_push_front.s
├── ft_list_remove_if.s
├── ft_list_size.s
├── ft_list_sort.s
├── ft_read.s
├── ft_strcmp.s
├── ft_strcpy.s
├── ft_strdup.s
├── ft_strlen.s
└── ft_write.s
I've got a Mac app that I'm building with clang and make. It needs a bunch of resource files that my makefile puts in foo.app/Contents/Resources but when I open the app from Finder, it fails to find those files. Let's say the file I'm trying to read is foo.app/Contents/Resources/myfile; a call like ifstream(myfile) fails (at least, the stream reports is_open == false).
I put in a call to filesystem::current_path() and it reports that it's in the directory where the app is located. And sure enough, if I prepend foo.app/Contents/Resources/ to myfile, ifstream("foo.app/Contents/Resources/myfile") finds it and opens it just fine.
But that's not how it's supposed to work. Can anyone tell me what I'm doing wrong? Thanks!
If it helps, my Makefile:
CC = clang++
CFLAGS = -g -O3 -std=c++11 -Wall -Wno-c++11-extensions
# CFLAGS = -g -std=c++11 -Wall -Wno-c++11-extensions -fsanitize=address
# CFLAGS = -g -std=c++11 -Wall -Wno-c++11-extensions
TARGET = nfl
SRCS = nfl.cpp
OTHER_SRCS = actions.cpp info.cpp io.cpp model.cpp
OBJS = $(SRCS:.cpp=.o)
OTHER_OBJS = $(OTHER_SRCS:.cpp=.o)
WX_CONFIG = ./wx-config
NFL_VERSION = 0.1
CXX_EXTRA = -mmacosx-version-min=10.9 `$(WX_CONFIG) --cxxflags` -DWX_PRECOMP
LINK_EXTRA = -mmacosx-version-min=10.9 `$(WX_CONFIG) --libs` -lm
$(TARGET): $(OBJS) $(OTHER_OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(OTHER_OBJS) $(LINK_EXTRA)
convert: convert.o io.o
$(CC) $(CFLAGS) -o convert convert.o io.o
%.o:
$(CC) $(CFLAGS) $(CXX_EXTRA) -c $<
app:
mkdir -p nfl.app/Contents
mkdir -p nfl.app/Contents/MacOS
mkdir -p nfl.app/Contents/Resources
sed -e "s/VERSION/$(NFL_VERSION)/" \
Info.plist.in >nfl.app/Contents/Info.plist
echo -n "APPL????" >nfl.app/Contents/PkgInfo
cp nfl nfl.app/Contents/MacOS/nfl
cp -f wxmac.icns nfl.app/Contents/Resources/wxmac.icns
cp -f full.csv nfl.app/Contents/Resources
cp -f detailed_model nfl.app/Contents/Resources
cp -f elapsed_model nfl.app/Contents/Resources
app: nfl Info.plist.in wxmac.icns
deps:
$(CC) $(CFLAGS) $(CXX_EXTRA) -MM $(SRCS) $(OTHER_SRCS)
clean:
rm -f $(TARGET) *.o
convert.o: convert.cpp data.h
model.o: model.cpp data.h
io.o: io.cpp data.h
nfl.o: nfl.cpp nfl.h data.h
actions.o: actions.cpp nfl.h data.h
info.o: info.cpp nfl.h data.h
and my Info.plist.in file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIdentifier</key>
<string>mattginsberg.com</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>nfl</string>
<key>CFBundleIconFile</key>
<string>wxmac.icns</string>
<key>CFBundleName</key>
<string>nfl</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>VERSION</string>
<key>CFBundleShortVersionString</key>
<string>VERSION</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2020 Matthew Ginsberg LLC.</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
I built wxWidgets with --enable-debug --disable-shared.
I have project folder with src, obj and inc dirs.
I declare var with obj - OBJS
SDIR = src
ODIR = obj
# I change /src/*.c to /obj/*.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
# I need to change /src/*.o to /obj/*.o
OBJS = $(??? $ODIR ??? $_OBJS ???)
Now in _OBJS - ./src/*.o, How to change in OBJS /src/ to /obj/?
Thanks.
What about this (if I understand the question correctly):
SDIR = src
ODIR = obj
# I change /src/*.c to /obj/*.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
# I need to change /src/*.o to /obj/*.o
_OBJS := $(subst $(SDIR), $(ODIR), $(_OBJS))
debug:
#echo $(_OBJS)
Output/Test:
$ mkdir ./src/
$ touch ./src/a.c
$ touch ./src/b.c
$ touch ./src/c.c
$ ls ./src/
a.c b.c c.c
$ make debug
obj/a.o obj/b.o obj/c.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
_OBJS := $(notdir $(_OBJS))
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
But, I think, its bad way
I want develop a generic makefile for the folowing architecture:
30/04/2015 18:10 <REP> .
30/04/2015 18:10 <REP> ..
30/04/2015 18:08 <REP> exe
30/04/2015 17:22 <REP> headers
30/04/2015 17:53 726 makefile.txt
30/04/2015 18:08 <REP> objects
30/04/2015 17:53 <REP> sources
with:
The content of sources
30/04/2015 17:53 <REP> .
30/04/2015 17:53 <REP> ..
30/04/2015 17:22 124 main.c
and the content of headers:
30/04/2015 17:22 <REP> .
30/04/2015 17:22 <REP> ..
30/04/2015 17:22 20 myheader.h
Objects : contents the output object files.
exe: contents the executable
When I put the header files and sources in the same directory, the makefile generates the output. But when I separate them, the make generates an error during dependency.
Here is my current makefile:
SRCDIRS = ../Mydirectory/sources
HDRDIRS = ../Mydirectory/headers
SRCEXTS = .c
HDREXTS = .h
OUTPUT = Output
CC= gcc
SOURCES = $(foreach file,$(SRCDIRS),$(wildcard $(addprefix $(file)/*,.c)))
HEADERS = $(foreach file,$(HDRDIRS),$(wildcard $(addprefix $(file)/*,.h)))
OBJS = $(addsuffix .o, $(basename $(SOURCES)))
DEPS = $(OBJS:.o=.d)
DEP_OPT = -M
DEPEND = $(CC) $(DEP_OPT)
DEPEND.d = $(subst -g ,,$(DEPEND))
COMPILE.c = $(CC) -c -I $(HDRDIRS)
LINK.c = $(CC)
all: $(OUTPUT)
%.d:%.c
[TAB]#echo -n $(dir $<) > $#
#$(DEPEND.d) $< >> $#
objs:$(OBJS)
%.o:%.c
[TAB]$(COMPILE.c) $< -o $#
$(OUTPUT):$(OBJS)
[TAB]$(LINK.c) $(OBJS) -o $#
clean:
[TAB]$(RM) $(OBJS) $(OUTPUT).exe
Update:
The makefile is in Mydirectory.
The output of make -f makefile.txt :
in MS-DOS:
gcc -c -I ../Mydirectory/headers ../Mydirectory/sources/main.c -o ../Mydirectory/sources/main.o
gcc ../Mydirectory/sources/main.o -o Output
And two files are created:
objects/main.o
Mydirectory/Output.exe