1

我有一个 Eclipse 管理的 make c++ 项目,其中源代码位于几个子目录中,其中一个目录名为“test”。Eclipse 会自动为每个子目录 (Debug/test/subdir.mk) 创建 makefile,并且该部分运行良好。

但是,如果我在项目属性中更改编译器(比如 icpc 而不是 gcc),则主 makefile(Debug/makefile)会更改为使用新编译器,但 subdir.mk 不会更改。subdir.mk 仍然有 gcc,而 Debug/makefile 有 icpc 作为编译器命令。我尝试为每个子目录设置属性,但我仍然遇到同样的问题。

我正在使用 Eclipse 火星

有什么办法可以改变这个吗?

这是调试/生成文件############################################ ################################### 自动生成的文件。不要编辑!################################################# ##############################

-include ../makefile.init
RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include test/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: TestProject

# Tool invocations
TestProject: $(OBJS) $(USER_OBJS)
        @echo 'Building target: $@'
        @echo 'Invoking: GCC C++ Linker'
        icpc -L<LinkerStuff> -lrt -openmp -inline-forceinline -o "TestProject" $(OBJS) $(USER_OBJS) $(LIBS)
        @echo 'Finished building target: $@'
        @echo ' '

# Other Targets
clean:
        -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) TestProject
        -@echo ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets

这是 Debug/test/subdir.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../test/TestProject.cpp

OBJS += \
./test/TestProject.o

CPP_DEPS += \
./test/TestProject.d


# Each subdirectory must supply rules for building sources it contributes
test/TestProject.o: ../test/TestProject.cpp
        @echo 'Building file: $<'
        @echo 'Invoking: GCC C++ Compiler'
        icc-I<includes stuff> -O3 -g3 -Wall -c -fmessage-length=0 -openmp -MMD -MP -MF"$(@:%.o=%.d)" -MT"test/TestProject.d" -o "$@" "$<"
        @echo 'Finished building: $<'
        @echo ' '
4

1 回答 1

1

看起来您只是将链接命令从 gcc 更改为 ipcc 而不是编译命令。顶级 makefile 执行链接(收集*.o到 exe),其中子目录执行单个对象编译(编译*.c*.o)。

此屏幕截图可能会有所帮助。箭头指向编译和链接构建设置:

链接

于 2015-10-17T10:07:52.727 回答