How can I give my sourcepaths to gcc
?
如何将源路径提供给gcc?
I have my .c
files in source and test directory.
我在源和测试目录中有我的.c文件。
How can I give gcc
the path to it? Im compiling with a
makefile` and always get the message
我怎样才能给gcc提供它的路径?我用amakefile`编译并始终得到消息
"no such file or directory test.c"
“没有这样的文件或目录test.c”
My directory structure:
我的目录结构:
make-directory|
|
|--source
|
|--Header
|
|--test
|
|--out
|
as asked:
# makefile to generate UNIT-tests
# define any directories containing header files other than /usr/include
# TODO
HEADERS = :../CUnit/headers \
CUnit/sources/Automated \
CUnit/sources/Basic \
CUnit/sources/Console \
CUnit/sources/Curses \
CUnit/sources/Framework \
CUnit/sources/Test \
CUnit/sources/Win \
CUnit/sources/wxWidget \
stub \
../source \
test
SOURCES = CUnit/headers \
CUnit/sources/Automated \
CUnit/sources/Basic \
CUnit/sources/Console \
CUnit/sources/Curses \
CUnit/sources/Framework \
CUnit/sources/Test \
CUnit/sources/Win \
CUnit/sources/wxWidget \
stub \
source \
test
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =
# TODO define the C source files
TST_SRCS = min.c max.c
SRCS = CUnit.c Automated.c Basic.c Console.c CUCurses.c CUError.c Cunit_intl.c \
MyMem.c TestDB.c TestRun.c Util.c wxWidget.c \
$(TST_SRCS)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
#OBJ = $(SRCS:%.c=%.o)
OBJ = $(TST_SRCS:%.c=%.o)
#OBJ=$(join ($(SOURCES)), $(notdir $(SRCS:%.c=%.o)))
# define the C compiler to use
CC = gcc
# define any compile-time flags
CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
VPATH=source
# define the executable file,
TARGET = CUnit
all:
$(CC) -I $(HEADERS) $(CFLAGS) $(OBJ) -o $(TARGET) $(LFLAGS)
1 个解决方案
#1
You can make use of vpath
or VPATH
in makefile to point to the directory containing the source files.
您可以在makefile中使用vpath或VPATH指向包含源文件的目录。
See the online gnu make manual here.
请在此处查看在线gnu make手册。
#1
You can make use of vpath
or VPATH
in makefile to point to the directory containing the source files.
您可以在makefile中使用vpath或VPATH指向包含源文件的目录。
See the online gnu make manual here.
请在此处查看在线gnu make手册。