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 / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

Linking Between Two Projects in a Solution

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sami Lakka - 21 Mar 2007 08:34 GMT
I have a solution with a two projects. The first project contains my classes
and an executable using those classes. The second project contains unit
tests for the classes. Because the unit test framework that I use requires a
main function I have to keep the tests in a separate project. Now when I try
to link the unit test project I get a lot of "Error LNK2019: unresolved
external symbol" errors. Both projects compile just fine and and the first
project creates OBJ files in the output directory. What should I do so that
the linker in the unit test project correctly links with the OBJ files of
the first project? Both of these projects should create executables.
adebaene@club-internet.fr - 21 Mar 2007 14:22 GMT
On 21 mar, 08:34, "Sami Lakka" <sami.la...@watechnologies.no_spam.com>
wrote:
> I have a solution with a two projects. The first project contains my classes
> and an executable using those classes. The second project contains unit
[quoted text clipped - 5 lines]
> the linker in the unit test project correctly links with the OBJ files of
> the first project? Both of these projects should create executables.

You need to add a reference to the 1st project in the 2nd project.

In Visual Studio 2005, right-click on the 2nd project in Solution
Explorer -> "References..." -> "Add New Reference" -> "Projects" Tab -
> choose your 1st project.

Arnaud
MVP - VC
Ben Voigt - 21 Mar 2007 14:38 GMT
> On 21 mar, 08:34, "Sami Lakka" <sami.la...@watechnologies.no_spam.com>
> wrote:
[quoted text clipped - 18 lines]
> Explorer -> "References..." -> "Add New Reference" -> "Projects" Tab -
>> choose your 1st project.

That will only work for pure managed exes, or dll assemblies, because native
mixed exe assemblies aren't relocatable.

You probably will end up moving your common testable code into a dll.
That's needed for reusability in .NET anyway.  In native C++, source code
reuse is a viable option as well, but that's what you're up against right
now.

If you want the same compiler options, package those .obj files into a
library (dll or static .lib).  If you need different compiler settings,
include the source files in both projects.
Arnaud Debaene - 21 Mar 2007 23:03 GMT
>> On 21 mar, 08:34, "Sami Lakka" <sami.la...@watechnologies.no_spam.com>
>> wrote:
[quoted text clipped - 22 lines]
> That will only work for pure managed exes, or dll assemblies, because
> native mixed exe assemblies aren't relocatable.

Dooh! I missed the fact that the 1st project was an exe, sorry about that
:-(

> If you want the same compiler options, package those .obj files into a
> library (dll or static .lib).
Indeed. This is of course the solution....

Arnaud
MVP - VC

Rate this thread:







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.