<ad******@club-internet.frwrote in message
news:11*********************@y66g2000hsf.googlegro ups.com...
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
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.
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.
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.