ld.exe权限被拒绝生成文件gcc
我想编译和链接我的项目。我对目标的链接有问题。这是我第一次使用makefile 我认为$OBJ或gcc的调用可能有问题 我收到以下错误消息:ld.exe权限被拒绝生成文件gcc,c,windows,gcc,makefile,linker,C,Windows,Gcc,Makefile,Linker,我想编译和链接我的项目。我对目标的链接有问题。这是我第一次使用makefile 我认为$OBJ或gcc的调用可能有问题 我收到以下错误消息: C:\Projekte\playground\Modultest>make all gcc -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage ./CUnit/headers ./CUnit/sources ./stub ./source ./test --coverage
C:\Projekte\playground\Modultest>make all
gcc -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage ./CUnit/headers ./CUnit/sources ./stub ./source ./test --coverage -o CUnit-Target
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find ./CUnit/headers: Permission denied
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find ./CUnit/sources: Permission denied
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find ./stub: Permission denied
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find ./source: Permission denied
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find ./test: Permission denied
collect2.exe: error: ld returned 1 exit status
makefile:54: recipe for target 'CUnit-Target' failed
make: *** [CUnit-Target] Error 1
我的路径中没有空格
这是我的makefile
# makefile to generate UNIT-tests
# define the C compiler to use
CC = gcc
# define any compile-time flags
CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
# define any directories containing header files other than /usr/include
# TODO
HEADERS = ./CUnit/headers \
./CUnit/sources \
./stub \
./source \
./test
SOURCES = ./CUnit/sources \
./stub \
./source \
./test
#TODO Linkerflags
LFLAGS = --coverage -o
# 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($(dir $(SOURCES))), $(notdir $(SRCS:%.c=%.o)))
# define the executable file
TARGET = CUnit-Target
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $(HEADERS) $(OBJ) $(LFLAGS) $(TARGET)
@echo build finished
#execute tests
#Cunit.exe
# create coverage files
# TODO SRCS max.c min.c ?
# gcov -b -c -f max min
clean:
$(RM) *.o *~ $(MAIN)
# DO NOT DELETE THIS LINE -- make depend needs it
我可以告诉您,在
OBJ
的赋值中,在join
之后缺少一个空格(这就是OBJ
最终为空的原因),并且由于某种原因,包含目录列表的名为HEADERS
的变量在编译器调用中没有位置,$(dir$(SOURCES))
可能没有达到您期望的效果($(dir./CUnit/headers)
是/CUnit
),但坦率地说,从这个Makefile中看不出您的项目是如何组织的,所以我不确定解决这些问题是否能让您编译它。您是对的。将行更改为OBJ=$(join($(SOURCES)),$(notdir$(SRCS:%.c=%.o)),并将-i$(HEADERS)添加到编译器的调用中。仍然存在编译器找不到源代码的问题。路径有问题。C:\Projekte\playway\moduletest>make all make:**“CUnit target”不需要任何规则来生成目标“(./CUnit/sourcesCUnit.o”。停止。您希望join
函数做什么?我想给gcc文件的路径。