From: wojciechfialkiewicz on
hello,

I'm using Visual Studio 6.0,
In single workspace i have created two projects A and B, they both are
console application programs,
In project A i have class a which i want to use in project B, i have
set dependency in project B to project A, but when i compile project B
i get the error error
"LNK2001: unresolved external symbol "public: virtual __thiscall
a::~a(void)" (??1a@@UAE(a)XZ)
error LNK2001: unresolved external symbol "public: __thiscall
a::a(void)" (??0a@@QAE(a)XZ)"

what to do ?
From: Giovanni Dicanio on

<wojciechfialkiewicz(a)gmail.com> ha scritto nel messaggio
news:4d2a03ab-485f-49df-a36f-31a8621ee4be(a)a23g2000hsc.googlegroups.com...

> I'm using Visual Studio 6.0,
> In single workspace i have created two projects A and B, they both are
> console application programs,
> In project A i have class a which i want to use in project B, i have
> set dependency in project B to project A, but when i compile project B
> i get the error error
> "LNK2001: unresolved external symbol "public: virtual __thiscall
> a::~a(void)" (??1a@@UAE(a)XZ)
> error LNK2001: unresolved external symbol "public: __thiscall
> a::a(void)" (??0a@@QAE(a)XZ)"
>
> what to do ?

If your projects are both console applications, and class A is in common,
you may share class A header and source files between the two projects, or
you may define a new (3rd) project: a static library, in which you define
class A. Then you can share the ClassA.lib and ClassA.h header between the
two .exe's.

Giovanni



From: Joseph M. Newcomer on
This is not surprising; it is doing exactly what it is supposed to do.

First, if there is a common source file used in both A and B, project B must include that
source file in its list of source files to compile. That's the simplest way, and rather
important. Then there is no dependency between the two.

But putting a dependency between the two, and failing to put the source file
...\A\whatever.cpp in the source files of B, is wrong. In addition, if you try to do it
this way, you have obviously neglected to tell the linker that it should include
whatever.obj in the link.

Just add the source file to the B project. Click on the B project, Add>Existing, go up
and back down to the A directory, and click on the file(s) to be included. Done.

I tend to do this by putting common source files in a sibling directory.

No dependency is required if you handle it in this fashion.
joe

On Wed, 14 May 2008 03:51:10 -0700 (PDT), wojciechfialkiewicz(a)gmail.com wrote:

>hello,
>
>I'm using Visual Studio 6.0,
>In single workspace i have created two projects A and B, they both are
>console application programs,
>In project A i have class a which i want to use in project B, i have
>set dependency in project B to project A, but when i compile project B
>i get the error error
>"LNK2001: unresolved external symbol "public: virtual __thiscall
>a::~a(void)" (??1a@@UAE(a)XZ)
>error LNK2001: unresolved external symbol "public: __thiscall
>a::a(void)" (??0a@@QAE(a)XZ)"
>
>what to do ?
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Ching on
<wojciechfialkiewicz(a)gmail.com> wrote in message
news:4d2a03ab-485f-49df-a36f-31a8621ee4be(a)a23g2000hsc.googlegroups.com...
> hello,
>
> I'm using Visual Studio 6.0,
> In single workspace i have created two projects A and B, they both are
> console application programs,
> In project A i have class a which i want to use in project B, i have
> set dependency in project B to project A, but when i compile project B
> i get the error error
> "LNK2001: unresolved external symbol "public: virtual __thiscall
> a::~a(void)" (??1a@@UAE(a)XZ)
> error LNK2001: unresolved external symbol "public: __thiscall
> a::a(void)" (??0a@@QAE(a)XZ)"
>
> what to do ?

Is 'project A' a .dll file that is supposed to export 'class a'? If so,
make sure the class is declared as __declspec(dllexport).


-- David