devc++如何编译多个源代码的文件
《c primer plus》第228页的酒店管理项目,在devc++中建立一个项目,然后添加一个头文件,两个源文件,项目无法编译,生成的makefile.win文件内容在最后面,怀疑是其中的路径有中文,请教下解决方法。gcc.exe: fatal error: no input files
compilation terminated.
D:\DevCprojects\p227\Makefile.win:26: recipe for target 'p227.exe' failed
mingw32-make.exe: *** [p227.exe] Error 1
编译结果...
--------
- 错误: 1
- 警告: 0
- 编译时间: 0.59s
代码是复制的原文:
hotel.h:
#define QUIT 5
#define HOTEL1 180.00
#define HOTEL2 225.00
#define HOTEL3 255.00
#define HOTEL4 355.00
#define DISCOUNT 0.95
#define STARS "**********************************"
hotel.c
#include <stdio.h>
#include "hotel.h"
int menu(void)
{
int code, status;
printf("\n%s%s\n", STARS, STARS);
printf("Enter the number of the desired hotel:\n");
printf("1) Fairfield Arms 2) Hotel Olympic\n");
printf("3) Chertworthy Plaza 4) The Stockton\n");
printf("5) quit\n");
printf("%s%s\n", STARS, STARS);
while ((status = scanf("%d", &code)) != 1 ||
(code < 1 || code > 5))
{
if (status != 1)
scanf("%*s"); // 处理非整数输入
printf("Enter an integer from 1 to 5, please.\n");
}
return code;
}
int getnights(void)
{
int nights;
printf("How many nights are needed? ");
while (scanf("%d", &nights) != 1)
{
scanf("%*s"); // 处理非整数输入
printf("Please enter an integer, such as 2.\n");
}
return nights;
}
void showprice(double rate, int nights)
{
int n;
double total = 0.0;
double factor = 1.0;
for (n = 1; n <= nights; n++, factor *= DISCOUNT)
total += rate * factor;
printf("The total cost will be $%0.2f.\n", total);
}
usehotel.c
int main(void)
{
int nights;
double hotel_rate;
int code;
while ((code = menu()) != QUIT)
{
switch (code)
{
case 1: hotel_rate = HOTEL1;
break;
case 2: hotel_rate = HOTEL2;
break;
case 3: hotel_rate = HOTEL3;
break;
case 4: hotel_rate = HOTEL4;
break;
default: hotel_rate = 0.0;
printf("Oops!\n");
break;
}
nights = getnights();
showprice(hotel_rate, nights);
}
printf("Thank you and goodbye.\n");
return 0;
}
makefile.win
# Project: p227
# Makefile created by Dev-C++ 6.7.5
CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
OBJ =
LINKOBJ =
LIBS = -L"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/" -L"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/" -L"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/mingw32/lib/" -L"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/" -L"D:/软件下载/安装包和安装程序/devcplusplus/Dev-Cpp/MinGW32/lib" -L"D:/软件下载/安装包和安装程序/devcplusplus/Dev-Cpp/MinGW32/mingw32/lib" -g3 -static
INCS = -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/include" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include-fixed"
CXXINCS = -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include/c++" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include/c++/mingw32" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include/c++/backward" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/include" -I"d:/软件下载/安装包和安装程序/devcplusplus/dev-cpp/mingw32/lib/gcc/mingw32/9.2.0/include-fixed"
BIN = p227.exe
CXXFLAGS = $(CXXINCS) -Wall -Wextra -g3
ENCODINGS = -finput-charset=utf-8 -fexec-charset=gbk
CFLAGS = $(INCS) -Wall -Wextra -g3
RM = del /q /f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "$(BIN)" $(LIBS)