Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / December 2004

Tip: Looking for answers? Try searching our database.

More projects in a C++ solution: how to link them together?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Agoston Bejo - 16 Dec 2004 19:56 GMT
Hi!
I have two projects, one depending on another. In the first a global
variable is defined:
x.hpp:
extern int x;
x.cpp:
int x = 5;

When in the second project I try to use this global variable, I get a linker
error:
[...].obj : error LNK2001: unresolved external symbol

How do I tell the linker to also use the object files from the first
project? Or is it such that global variables are only "project-global" but
cannot be made "solution-global"?

Thx,
Agoston
Igor Tandetnik - 16 Dec 2004 20:14 GMT
> 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
Victor Bazarov - 16 Dec 2004 20:15 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.