简体   繁体   English

c ++ visual studio 2008问题,在一个解决方案中有两个项目

[英]c++ visual studio 2008 issue with two projects in one solution

I have a solution created using visual studio 2008 named, " Solution ", and i have two projects in that solution, project " A " and project " B ". 我有一个使用Visual Studio 2008创建的解决方案 ,名为“ 解决方案 ”,在该解决方案中有两个项目,项目“ A ”和项目“ B ”。 when i do a thing like below it shows fatal errors in the bottom. 当我做下面的事情时,它在底部显示致命错误。 I have given in project A->properties->Additional include Directries as ../B 我在项目A-> properties-> Additional include Directries中给出了../B

project B 项目B

Bh h

#include <iostream>

using namespace std;
class B
{
public:
    B();
    ~B();
};

B.cpp 丙型肝炎

#include "B.h"

B::B()
{

}

B::~B()
{

}

project A 项目A

Ah

#include <iostream>

using namespace std;
class A
{
public:
    A();
    ~A();
};

A.cpp 丙型肝炎

#include "A.h"
#include "B.h"
A::A()
{
    B b;
}

A::~A()
{

}

Main.cpp in project A 项目A中的Main.cpp

#include "B.h"

int main()
{
    B b;
    system("pause");
}

when i run it says 当我运行它说

Error 3 fatal error LNK1120: 2 unresolved externals H:\\Sol\\Debug\\A.exe 错误3致命错误LNK1120:2个未解析的外部文件H:\\ Sol \\ Debug \\ A.exe

Error 2 error LNK2001: unresolved external symbol "public: __thiscall B::B(void)" (??0B@@QAE@XZ) A.obj 错误2错误LNK2001:无法解析的外部符号“ public:__thiscall B :: B(void)”(?? 0B @@ QAE @ XZ)A.obj

Error 1 error LNK2001: unresolved external symbol "public: __thiscall B::~B(void)" (??1B@@QAE@XZ) A.obj 错误1错误LNK2001:无法解析的外部符号“ public:__thiscall B ::〜B(void)”(?? 1B @@ QAE @ XZ)A.obj

It doesn't look like you are exporting class B out of project B. So project A sees the declaration of class B but can't find its implementation. 看起来您不是从项目B中导出类B。因此项目A看到了类B的声明,但找不到其实现。 What does project B build? 项目B构建什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM