一个有关源程序在编译与链接时的问题
我在写完程序运行时,发现有以下问题:
一:这个是在运行时给出的一个对话框中的话,需要选择是否继续,如果继续则程序运行,并且能够得到正确结果。源程序如下
Error reading debug infomation:build with invalid linker.Run anyway?
#include<iostream.h>
int global;
void f()
{global=5;}
void g()
{cout<<global<<endl;}
int main()
{
f();
g();
return 0;
}
二:在编译与链接运行下面这个程序时就没有上面那个幸运了,编译器直接给出错误信息,程序无法运行。如下:
Linker Warning:No module definition file specified:using defaults
Linker Error:Undefined symbol OwlMain(int,char far*far*) in library file d:\bc4\lib\owlwi.lib in module winmain
#include<iostream.h>
class point
{
public:
point(int xx=0,int yy=0){x=xx;y=yy;countp++;}
point(point &p);
int getx(){return x;}
int gety(){return y;}
void getc(){cout<<"Object id="<<countp<<endl;}
private:
int x,y;
static int countp;
};
point::point(point &p)
{
x=p.x;
y=p.y;
countp++;
}
int point::countp=0;
void main()
{
point a(4,5);
cout<<"Point A,"<<a.getx()<<","<<a.gety();
a.getc();
point b(a);
cout<<"Point B,"<<b.getx()<<","<<b.gety();
b.getc();
}
后来我修改了一下directory:将lib库的目录由d:\bc4\lib改为d:\bc4\lib;d:\bc4\owl\lib,结果出现下面的错误信息,程序依然无法运行。
Linker Fatal:unable to open file 'cOwl.obj'
我现在有两点疑问:这是怎么回事?还有,为什么我将directory修改后会有变化,而d:\bc4\owl\lib是实际中不存在的啊。
恳请各位给予解答。