如何将SourceFilePath提供给gcc?
如何将我的源路径提供给如何将SourceFilePath提供给gcc?,c,gcc,makefile,C,Gcc,Makefile,如何将我的源路径提供给gcc 我的.c文件位于源代码和测试目录中 我怎样才能给它提供路径?我用一个makefile`编译,并且总是能得到消息 “没有这样的文件或目录test.c” 我的目录结构: make-directory| | |--source | |--Header | |--test |
gcc
我的.c
文件位于源代码和测试目录中
我怎样才能给它提供路径?我用一个makefile`编译,并且总是能得到消息
“没有这样的文件或目录test.c”
我的目录结构:
make-directory|
|
|--source
|
|--Header
|
|--test
|
|--out
|
被问及:
# 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)
您可以使用makefile中的
vpath
或vpath
指向包含源文件的目录
请参阅此处的联机文档。请提供您的制作文件