Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MFC in a static library link problem

224 views
Skip to first unread message

Nikos Karelos

unread,
Nov 29, 2001, 3:15:16 AM11/29/01
to
Hello all,

I want to link a project of mine, developed in VC++, using MFC, by
statically linking the MFC libraries, so as the executable to run on a PC
without MSVC installed. Although all this time, this has caused me no
problem at all, and it linked successfully, when I tried to do it yesterday,
I got the following linker errors :

nafxcw.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator
new(unsigned int)" (??2@YAPAXI@Z) already defined in msvcrt.lib(MSVCRT.dll);
second definition ignored
nafxcw.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void
*)" (??3@YAXPAX@Z) already defined in msvcrt.lib(MSVCRT.dll); second
definition ignored
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol
__mbctype
nafxcw.lib(filelist.obj) : error LNK2001: unresolved external symbol
__mbctype
nafxcw.lib(timecore.obj) : error LNK2001: unresolved external symbol
__mbctype

I could find no help on those, and I tried to change the order of the
library paths, setting the MSVC paths first, but nothing changed. When I use
MFC libraries in a shared DLL the project links successfully... And this
happens with both Release and Debug versions.

I explicitly exclude "libc.lib" and "libcmt.lib" with the /nodefaultlib
directive, as instructed, because I get unresolved externals and conflicts.
The calling convention I use in the C/C++ tab of the project settings is
stdcall, and I have to use this, as cdecl causes problem with the libraries
I use...

What could be wrong and I get these error messages?

Any hint would be greatly appreciated,

Thank you in advance,

Regards,

Nikos


John

unread,
Nov 29, 2001, 3:28:59 AM11/29/01
to

"Nikos Karelos" <nkar...@profile.gr> wrote in message
news:uxld55KeBHA.1432@tkmsftngp04...

>
> nafxcw.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator
> new(unsigned int)" (??2@YAPAXI@Z) already defined in
msvcrt.lib(MSVCRT.dll);
> second definition ignored

Try adding msvcrt.lib to the "Ignore libraries:" section in
Project|Settings|Link|Output

John.


John

unread,
Nov 29, 2001, 3:36:38 AM11/29/01
to

"John" <nos...@hotmail.com> wrote in message
news:eQx4Q$KeBHA.2124@tkmsftngp03...

Actually that's probably not the answer, it looks like nafxcw.lib is linking
to the dll, you'll have to check how nafxcw.lib is linking and try to fix
that.


Nikos Karelos

unread,
Nov 29, 2001, 4:00:29 AM11/29/01
to
Hello John,

Thank you for the reply...

> Actually that's probably not the answer, it looks like nafxcw.lib is
linking
> to the dll, you'll have to check how nafxcw.lib is linking and try to fix
> that.

Erm... how am I supposed to do that? And why has it not caused me problems
earlier? What could be different? Actually, I had no knowledge of this
particular library. I suppose it is one of the basic MFC libraries...

Thank you for the help,

Regards,

Nikos


John Larocca

unread,
Nov 29, 2001, 9:16:49 AM11/29/01
to
That sound familiar.
Check out the microsoft paper :

http://support.microsoft.com/support/kb/articles/q148/6/52.asp

John


"Nikos Karelos" <nkar...@profile.gr> wrote in message
news:uxld55KeBHA.1432@tkmsftngp04...

John

unread,
Nov 29, 2001, 12:09:39 PM11/29/01
to

"Nikos Karelos" <nkar...@profile.gr> wrote in message
news:#bcPKTLeBHA.2680@tkmsftngp07...

>
> Erm... how am I supposed to do that? And why has it not caused me problems
> earlier? What could be different? Actually, I had no knowledge of this
> particular library. I suppose it is one of the basic MFC libraries...
>
Well, from your original posting you seem to have a pretty good idea of
what's involved in statically linking MFC (more then I do). Have you added
any new .lib files to the project? When linking in other libraries, those
other libraries need be linking to the same CRT functions that your project
is. Maybe check the Code Generation under the C/C++ tab.
John.


Jeff Kohn

unread,
Nov 29, 2001, 2:00:35 PM11/29/01
to
You're probably linking to some third-party library that dynamically links.

Jeff

"Nikos Karelos" <nkar...@profile.gr> wrote in message

news:uxld55KeBHA.1432@tkmsftngp04...

Nikos Karelos

unread,
Nov 30, 2001, 2:44:04 AM11/30/01
to
Thank you all for your help.

The problem is solved, and as it seems it was due to ignoring the wrong
default libraries, in combination with "testing" the include paths order.

Best Regards,

Nikos


0 new messages