error LNK2005 
Author Message
 error LNK2005

I am getting a LNK2005 error for reasons I do not understand.
I have a very simple test case that exhibits this problem.

One project implements a standalone class, producing a header
file and a static .lib. No MFC. No ATL. As simple as it gets.

A second project (MFC Dialog App) instantiates an object of
the class from the first project. When building the second
project I get:

test_class_test error LNK2005: "public: __thiscall

test_class.lib(TestClass.obj)

Why is this being defined in the second project?

I can produce an executable from the second project by using
the "/FORCE:MULTIPLE" linker option, but that does not sit
well with me. There should not be "multiple".

I want to produce reusable standalone libs (project one) for different
apps (project two). What settings should I use for projects one and
two?

--
Mike Loftus (real email address does not contain error)
Ford Scientific Research Lab
Expressing my personal opinions, not necessarily those of Ford Motor Co.



Sun, 18 Sep 2005 03:35:26 GMT  
 error LNK2005

--------------------

Quote:

> Newsgroups: microsoft.public.dotnet.languages.vc
> Subject: error LNK2005
> Date: Tue, 1 Apr 2003 14:35:26 -0500
> I am getting a LNK2005 error for reasons I do not understand.
> I have a very simple test case that exhibits this problem.

> One project implements a standalone class, producing a header
> file and a static .lib. No MFC. No ATL. As simple as it gets.

> A second project (MFC Dialog App) instantiates an object of
> the class from the first project. When building the second
> project I get:

> test_class_test error LNK2005: "public: __thiscall

> test_class.lib(TestClass.obj)

> Why is this being defined in the second project?

> I can produce an executable from the second project by using
> the "/FORCE:MULTIPLE" linker option, but that does not sit
> well with me. There should not be "multiple".

> I want to produce reusable standalone libs (project one) for different
> apps (project two). What settings should I use for projects one and
> two?

> --
> Mike Loftus (real email address does not contain error)
> Ford Scientific Research Lab
> Expressing my personal opinions, not necessarily those of Ford Motor Co.

Hello Mike,

Could you please provide some code which reproduces this problem? Also what
version of VC++ are you using?

--
Tanveer Gani, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Sat, 24 Sep 2005 02:03:45 GMT  
 error LNK2005


Quote:

> --------------------

> > Newsgroups: microsoft.public.dotnet.languages.vc

> > One project implements a standalone class, producing a header
> > file and a static .lib. No MFC. No ATL. As simple as it gets.

> > A second project (MFC Dialog App) instantiates an object of
> > the class from the first project. When building the second
> > project I get:

> > test_class_test error LNK2005: "public: __thiscall

> > test_class.lib(TestClass.obj)

> > Why is this being defined in the second project?

> > I can produce an executable from the second project by using
> > the "/FORCE:MULTIPLE" linker option, but that does not sit
> > well with me. There should not be "multiple".

> > I want to produce reusable standalone libs (project one) for different
> > apps (project two). What settings should I use for projects one and
> > two?

> Hello Mike,

> Could you please provide some code which reproduces this problem? Also
what
> version of VC++ are you using?

Thank you for replying.

I read the help page for the indicated error many times trying
to determine which condition applied to my case. It turned out to
be a "single-threaded" lib being linked to a "multi-threaded" app.
I had not selected multi-threading and was not aware that it was
the default for an MFC dialog app. I rebuilt the lib using the
multi-threaded runtime library and the problem was fixed.

[Still seems odd that I must select a thread support runtime
library for a static library. The same code (lib) should be
reusable in either single- or multiple-threaded apps.]

--
Mike Loftus (real email address does not contain error)
Ford Scientific Research Lab
Expressing my personal opinions, not necessarily those of Ford Motor Co.



Sun, 25 Sep 2005 21:03:10 GMT  
 error LNK2005

Quote:

> [...]
> [Still seems odd that I must select a thread support runtime
> library for a static library. The same code (lib) should be
> reusable in either single- or multiple-threaded apps.]

  You select which version of the RTL to
  link to and which inline functions to
  expand into your code. How could that
  be the same for both?

Quote:
> Mike Loftus (real email address does not contain error)

  Schobi

--

I'm Schobi at suespammers org



Fri, 30 Sep 2005 22:57:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Link Errors : error LNK2005 and LNK2004

2. VC 7.0 Linker Error LNK2005, LNK4006, LNK1169 _DllMain@12 already defined in MyDll.obj

3. error LNK2005

4. Linker Error LNK2005

5. using _variant_t rather than _bstr_t causing linker error LNK2005

6. error LNK2005: using MFC with ATL

7. help...Linker error: LNK2005

8. .obj/.lib/.dll and error LNK2005

9. error LNK2005.

10. Please Help! - Link Error LNK2005

11. help- Link error LNK2005

12. Linker Tools Error LNK2005

 

 
Powered by phpBB® Forum Software