【发布时间】:2015-07-25 04:47:33
【问题描述】:
我得到这个错误:
make all
Building file: ../src/lol.c
Invoking: GCC C Compiler
gcc -lm lol.c -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/lol.d" -MT"src/lol.d" -o "src/lol.o" "../src/lol.c"
gcc: error: lol.c: No such file or directory
make: *** [src/lol.o] Error 1
制作文件
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
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: lol
# Tool invocations
lol: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
gcc -o "lol" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) lol
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
SUBDIR.mk
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/lol.c
OBJS += \
./src/lol.o
C_DEPS += \
./src/lol.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
gcc -lm lol.c -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
当我尝试编译下面的代码时。我在 ubuntu 14.04lts 上使用 eclipse。我知道您可能需要有关错误的更多详细信息,但我不知道是什么以及如何,请询问您是否需要更多信息。
#include <stdio.h>
#include <math.h>
/* to be compiled with "gcc -lm 05_09.c" */
double calculateCharges(float hours);
int main(void)
{
float car_a_hours, car_b_hours, car_c_hours, tothours;
float car_a_charge, car_b_charge, car_c_charge, totcharge;
printf("\n\n");
printf("enter car #1 parking hours: ");
scanf("%f", &car_a_hours);
printf("enter car #2 parking hours: ");
scanf("%f", &car_b_hours);
printf("enter car #3 parking hours: ");
scanf("%f", &car_c_hours);
tothours = car_a_hours + car_b_hours + car_c_hours;
car_a_charge = calculateCharges(car_a_hours);
car_b_charge = calculateCharges(car_b_hours);
car_c_charge = calculateCharges(car_c_hours);
totcharge = car_a_charge + car_b_charge + car_c_charge;
printf("\n\n");
printf("Car\tHours\tCharge\n");
printf("%d\t%5.1f\t%6.2f\n", 1, car_a_hours, car_a_charge);
printf("%d\t%5.1f\t%6.2f\n", 2, car_b_hours, car_b_charge);
printf("%d\t%5.1f\t%6.2f\n", 3, car_c_hours, car_c_charge);
printf("TOTAL\t%5.1f\t%6.2f\n", tothours, totcharge);
printf("\n\n");
return 0;
}
double calculateCharges(float hours)
{
if ((hours - 3.0) <= 0)
return 2.0;
else if ((hours == 24.0))
return 10;
else
return (ceil(hours) - 3) * 0.5 + 2;
}
【问题讨论】:
-
我们需要错误输出中的 above 行。特别是关于代码中的错误等。
-
@dnt994 添加更多日志
-
显示生成文件。该编译命令显然很混乱(
lol.c有两次不同的路径)。 -
@EtanReisner 我在哪里以及如何做到这一点?对不起,我是个菜鸟:D
-
有问题的目标不在那个makefile中。它必须在其中列出的
included 生成文件之一中。
标签: c eclipse makefile ubuntu-14.04