0
我想許多編譯源文件彙編他們,但沒有將它們鏈接 我用一個makefile像下面gcc的錯誤:不能指定-c,並與多個文件
sources = $(wildcard absolut_path_to_source_files/*.c)
objects = absolut_path_to_source_files_folder
compile = $(foreach p,$(sources), gcc -c $(p) -o $(objects)/$(patsubst %.c,%.o,$(notdir $(p))))
all:
$(compile)
我得到一個gcc -o錯誤的兩個標誌-c
和-o
不能在同一時間對幾個源文件使用,
gcc: fatal error: cannot specify -o with -c, -S or -E with multiple files
compilation terminated.
這是一件好事,因爲它是foreach
功能,這對於調用gcc的內部使用的,我不明白一次只有一個源文件(迭代)。