Discussion:
Problem with static library using MFC and Linking
(too old to reply)
Josh McFarlane
2005-10-15 20:14:42 UTC
Permalink
I'm getting LNK2005 errors all over the place such as:

nafxcwd.lib(afxinl3.obj) : error LNK2005: "public: class CWnd *
__thiscall CWnd::GetOwner(void)const " (?***@CWnd@@***@XZ)
already defined in uafxcwd.lib(afxinl3.obj)

Basically it looks like it's trying to relink all of MFC two complete
times.

I've got two seperate projects, my main application, and a TCP
communication library I'd like to link.

Both link to MFC via static library.
Both are Multi-Threaded Debug.

Anyone know why the refuse to link? I include the header files from the
TCP project, and the generated LIB, but it still has issues all over
the place with the Linker errors.

When I switch to using MFC Shared DLL, I get

LINK : warning LNK4098: defaultlib 'mfc80d.lib' conflicts with use of
other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'mfcs80d.lib' conflicts with use of
other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of
other libs; use /NODEFAULTLIB:library

Which does compile, but worries me.

Anyone care to set me straight on how I should compile my app and my
library? (I also link a static library that uses just the standard
windows library, as well as another 3rd party library that I do not
know what it uses).

Thanks,
Josh McFarlane
David Lowndes
2005-10-17 14:34:22 UTC
Permalink
Post by Josh McFarlane
nafxcwd.lib(afxinl3.obj) : error LNK2005: "public: class CWnd *
already defined in uafxcwd.lib(afxinl3.obj)
You're linking ANSI and UNICODE modules:

ANSI: nafxcwd
UNICODE: uafxcwd

Check the project settings for both projects.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Josh McFarlane
2005-10-17 15:26:13 UTC
Permalink
Post by David Lowndes
Post by Josh McFarlane
nafxcwd.lib(afxinl3.obj) : error LNK2005: "public: class CWnd *
already defined in uafxcwd.lib(afxinl3.obj)
ANSI: nafxcwd
UNICODE: uafxcwd
Check the project settings for both projects.
Oh wow, now there is something I didn't even think about checking.

Thanks a bunch! I'll check this today when I go in and hopefully all
problems are fixed.

On a weird note, does not setting the char type default to ANSI?

Loading...