免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 2863 | 回复: 22
打印 上一主题 下一主题

打扰了, makefile问题, 这样的情况该怎么写 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-04-27 10:39 |只看该作者 |倒序浏览
论坛的一些精华确实经典, 不过对我来说就大材小用了. 我也试图取理解不过太紧了理解不了, 还请帮忙.
现在有三个目录(都在mydir下):
a(1.cpp和1.h文件),b(2.cpp和2.h文件),c(3.cpp和3.h文件)
每个目录下都有自己的头文件和cpp文件main函数在a目录的1文件.

我应该把makefile写到mydir下吗?
我这样下对不:
#INDIR=-I/usr/include/ -I./

A_DIR=./a
B_DIR=./b
C_DIR=./c

des:1.o 2.o 3.o            
        g++ -o $@ %^
               
1.o(A_DIR)/1.cpp $(A_DIR)/1.h
        g++ -c -o $@ $(A_DIR)/1.cpp
       
2o(B_DIR)/2.cpp $(B_DIR)/2.h
        g++ -c -o $@ $(A_DIR)/2.cpp
       
3.o(C_DIR)/3.cpp $(C_DIR)/3.h
        g++ -c -o $@ $(A_DIR)/3.cpp
       

或者应该把makefile下到a下面, 还是没有关系, 不过makefile文件这样写有什么问题?

论坛徽章:
0
2 [报告]
发表于 2004-04-27 11:39 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

大概看了一下 整体没什么问题

你贴make的出错信息阿

论坛徽章:
0
3 [报告]
发表于 2004-04-27 12:52 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

实际的makefile:
MAIN_DIR=./CompleteFile/
DB_DIR=./kiwiDB/
API_DIR=./com/

linkindextable(MAIN_DIR)/CompleteFile.o $(MAIN_DIR)/BackLead.o \
               $(DB_DIR)/DataBlockManageCls.o $(DB_DIR)/AllDataManageCls.o \
               $(DB_DIR)/ParsedRegionDataBlockCls.o $(API_DIR)/NAS_com_API.o               
        g++ -o $@ %^
               
CompleteFile.o(MAIN_DIR)/CompleteFile.cpp $(MAIN_DIR)/CompleteFile.h
        g++ -c -o $@ $(MAIN_DIR)/CompleteFile.cpp
       
BackLead.o(MAIN_DIR)/BackLead.cpp $(MAIN_DIR)/BackLead.h
        g++ -c -o $@ $(MAIN_DIR)/BackLead.cpp
       
DataBlockManageCls.o(DB_DIR)/DataBlockManageCls.cpp $(DB_DIR)/DataBlockManageCls.h
        g++ -c -o $@ $(DB_DIR)/DataBlockManageCls.cpp
       
AllDataManageCls.o(DB_DIR)/AllDataManageCls.cpp $(DB_DIR)/AllDataManageCls.h $(DB_DIR)/pubstruct.h
        g++ -c -o $@ $(DB_DIR)/AllDataManageCls.cpp
       
ParsedRegionDataBlockCls.o(DB_DIR)/ParsedRegionDataBlockCls.cpp $(DB_DIR)/ParsedRegionDataBlockCls.h
        g++ -c -o $@ $(DB_DIR)/ParsedRegionDataBlockCls.cpp
       
NAS_com_API.o(API_DIR)/NAS_com_API.cpp $(API_DIR)/NAS_com_API.h
        g++ -c -o $@ $(API_DIR)/NAS_com_API.cpp


错误信息如下:
./makefile: MAIN_DIR: command not found
./makefile: MAIN_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: API_DIR: command not found
./makefile: linkindextable:/CompleteFile.o: No such file or directory
g++: No input files
./makefile: MAIN_DIR: command not found
./makefile: MAIN_DIR: command not found
./makefile: CompleteFile.o:/CompleteFile.cpp: No such file or directory
./makefile: MAIN_DIR: command not found
g++: No input files
./makefile: MAIN_DIR: command not found
./makefile: MAIN_DIR: command not found
./makefile: BackLead.o:/BackLead.cpp: No such file or directory
./makefile: MAIN_DIR: command not found
g++: No input files
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: DataBlockManageCls.o:/DataBlockManageCls.cpp: No such file or directory
./makefile: DB_DIR: command not found
g++: No input files
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: AllDataManageCls.o:/AllDataManageCls.cpp: No such file or directory
./makefile: DB_DIR: command not found
g++: No input files
./makefile: DB_DIR: command not found
./makefile: DB_DIR: command not found
./makefile: ParsedRegionDataBlockCls.o:/ParsedRegionDataBlockCls.cpp: No such file or directory
./makefile: DB_DIR: command not found
g++: No input files
./makefile: API_DIR: command not found
./makefile: API_DIR: command not found
./makefile: NAS_com_API.o:/NAS_com_API.cpp: No such file or directory
./makefile: API_DIR: command not found
g++: No input files

论坛徽章:
0
4 [报告]
发表于 2004-04-27 13:10 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

MAIN_DIR = CompleteFile

论坛徽章:
0
5 [报告]
发表于 2004-04-27 13:23 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

试了试结果还是一样
是不认那三个变量?

论坛徽章:
0
6 [报告]
发表于 2004-04-27 13:27 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

我用了你一样的语法,没有问题.

论坛徽章:
0
7 [报告]
发表于 2004-04-27 13:36 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

我是在惠普机器上调的
不会和机器配置有关吧

论坛徽章:
0
8 [报告]
发表于 2004-04-27 13:54 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

原帖由 "smfyg" 发表:
我是在惠普机器上调的
不会和机器配置有关吧

刚好有环境,我在SCO506 REDHAT9 HP10 下均没有问题
Makefile 里有没有乱字符?
====================================
Makefile
dir=./
a(dir)/a.c
        echo "ff"
~

论坛徽章:
0
9 [报告]
发表于 2004-04-27 14:01 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

没有乱字符
我是通过网络映射驱动器用ultraedit编辑的,
不过通过telnet我用vi看了
确实没有乱字符, 回车换行也没问题

论坛徽章:
0
10 [报告]
发表于 2004-04-27 14:17 |只看该作者

打扰了, makefile问题, 这样的情况该怎么写

把MAIN_DIR=./CompleteFile/
DB_DIR=./kiwiDB/
API_DIR=./com/

改成
MAIN_DIR=./CompleteFile
DB_DIR=./kiwiDB
API_DIR=./com

试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP