> I have two projects, one depending on another. In the first a global
> variable is defined:
>
> When in the second project I try to use this global variable, I get a
> linker error:
> [...].obj : error LNK2001: unresolved external symbol
What kind of projects are these - EXE, DLL, something else? Is the first
project a static library project?

Signature
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Agoston Bejo - 16 Dec 2004 23:36 GMT
Actually they are two Win32 console EXE projects. From time to time I change
from one to the other, the first one contains some utilities and its exe
runs some basic test routines. The second one is the one that actually uses
it. (So far only only header files has been used - since there are only
various template definitions - , so this problem was not an issue at all.)
The second project also runs some basic tests.
Thx,
Agoston
> > I have two projects, one depending on another. In the first a global
> > variable is defined:
[quoted text clipped - 13 lines]
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
Arnaud Debaene - 17 Dec 2004 18:21 GMT
> Actually they are two Win32 console EXE projects.
You can't link 2 exes together! You can link a static lib or a DLL (through
it's import library) to another DLL or to an exe.
Arnaud
MVP - VC
> I have two projects, one depending on another. In the first a global
> variable is defined:
[quoted text clipped - 10 lines]
> project? Or is it such that global variables are only "project-global" but
> cannot be made "solution-global"?
Global variables are "target-global". I.e. their 'globality' is limited
by the bounds of the result of linking.
I presume at least one of your projects is a DLL (the one with the global
object 'x'). You need to add the .lib file that is built as a result of
linking that project to the other project's library list.
V