返回信息流rt,不知道该在哪儿问好。不过程序是C++写的,就在这儿问了。不对的话望版主包涵。:P
运行make TestQuery后,得到错误信息如下:
g++ -c -o Ledger.o Ledger.cpp
In file included from ProductCatalog.h:3,
from Storage.h:3,
from Ledger.h:4,
from Ledger.cpp:2:
ProductDescription.h:3:20: error: calling fdopen: Bad file descriptor
In file included from Storage.h:3,
from Ledger.h:4,
from Ledger.cpp:2:
ProductCatalog.h:5:20: error: calling fdopen: Bad file descriptor
In file included from Item.h:3,
from Storage.h:4,
from Ledger.h:4,
from Ledger.cpp:2:
Date.h:3:20: error: calling fdopen: Bad file descriptor
In file included from Ledger.h:4,
from Ledger.cpp:2:
Storage.h:5:20: error: calling fdopen: Bad file descriptor
make: *** [Ledger.o] Error 1
好像是Ledger.o在链接的时候出错了。
makefile相应项如下:
TestQuery: TestQuery.cpp TestFunction.o Query.o
g++ -o TestQuery TestQuery.cpp TestFunction.o Query.o
#nothing here
Ledger.o:
Ledger.h中是Ledger类声明,有两个函数定义在Ledger.cpp中。Ledger.h中饱含了如下文件:
3 #include "stdafx.h"
4 #include "Storage.h"
5 #include "ProductCatalog.h"
6 #include "Item.h"
这几个文件所有函数定义都在头文件中。stdafx.h Storage.h ProductCatalog.h有对应的.cpp文件,但里面只有一行#include.
如果把所有包含的文件加上,makefile改为
30 Ledger.o: Ledger.cpp stdafx.h Storage.h ProductCatalog.h Item.h
31 g++ -c Ledger.cpp stdafx.h Storage.h ProductCatalog.h Item.h
出错信息在原先基础上多了如下几行:
Storage.h:5:20: error: calling fdopen: Bad file descriptor
Storage.h:1:9: warning: #pragma once in main file
ProductCatalog.h:1:9: warning: #pragma once in main file
ProductCatalog.h:5:20: error: calling fdopen: Bad file descriptor
Item.h:1:9: warning: #pragma once in main file
make: *** [Ledger.o] Error 1
我想应该是makefile的问题,程序写的没错。不过不知道makefile该怎么写。望指教。谢谢!
这是一条镜像帖。来源:北邮人论坛 / cpp / #6043同步于 2008/5/1
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
[求助]问个makefile的问题
yellowxin
2008/5/1镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
不好使。那个我也看见了,有个人提交的g++的bug。但是我rm *.gch了还是出错。bad file descriptor,全指向包含stdafx.h的时候。
要疯了~
【 在 ttplayer 的大作中提到: 】
: baidu了一下:
: 删除目录下的 . gch就可以了
.