Solved

More MFC Linker Errors in VC++4.0 (LNK2005)

Posted on 1997-08-05
1
823 Views
Last Modified: 2013-11-20
I am having fits trying to link the simplest MFC app.

First of all, I can't get even an AppWizard-generated shell of a program to link dynamically using the mfc40d.dll. So, I
can't try some of the suggestions others have made to do
this in order to solve my LNK2005 problems. I would prefer
to link dynamically, if I could.

Here is the error I get, running with /verbose:lib and with
the included libraries of - mfc40d.lib msvcrtd.lib
3dPlusd.lib, in that order. No excluded libs.:

=== begin linker output ===
Linking...
LINK : LNK4073: cannot create map for .ILK file; linking
nonincrementally

Searching Libraries
    Searching H:\MSDEV\MFC\lib\mfc40d.lib:
    Searching H:\MSDEV\LIB\msvcrtd.lib:

LINK : error : Internal error during Pass1
link.exe terminated at user request.
test2.exe - 1 error(s), 0 warning(s)
=== end linker output ===


Next, I tried to link statically. This worked for my AppWizard
tiny program - a single TextOut statement in the view window.
But, when I tried to remove some classes, and insert some code
into CMyApp::InitInstance(), I get the LNK2005 errors.

Below is a sample, linked with included libraries
nafxcwd.lib libcmtd.lib 3dPlusd.lib (in that order), and
by *Ex*cluding mfc40d.lib and msvcrtd.lib.:

=== begin linker output ===
Linking...
LINK : LNK4073: cannot create map for .ILK file; linking
nonincrementally

Searching Libraries
    Searching H:\MSDEV\MFC\lib\nafxcwd.lib:
    Searching H:\MSDEV\LIB\libcmtd.lib:
    Searching h:\3dGraphics\3DPLUS\LIB\3dPlusd.lib:
    Searching H:\MSDEV\LIB\kernel32.lib:
    Searching H:\MSDEV\LIB\user32.lib:
    Searching H:\MSDEV\LIB\gdi32.lib:
    Searching H:\MSDEV\LIB\comdlg32.lib:
    Searching H:\MSDEV\LIB\winspool.lib:
    Searching H:\MSDEV\LIB\advapi32.lib:
    Searching H:\MSDEV\LIB\shell32.lib:
    Searching H:\MSDEV\LIB\comctl32.lib:
    Searching H:\MSDEV\LIB\OLDNAMES.lib:
    Searching H:\MSDEV\MFC\lib\mfc40d.lib:
mfc40d.lib(MFC40D.DLL) : error LNK2005: "protected: static struct
AFX_MSGMAP const  CWnd::messageMap"(?messageMap@CWnd@@1UAFX_MSGMAP@@B)
already defined in nafxcwd.lib(wincore.obj)
mfc40d.lib(MFC40D.DLL) : error LNK2005: "public: static struct
CRuntimeClass
CObject::classCObject"(?classCObject@CObject@@2UCRuntimeClass@@A)
already
defined in nafxcwd.lib(objcore.obj)
mfc40d.lib(MFC40D.DLL) : error LNK2005: "public: static struct
CRuntimeClass
CFileException::classCFileException"(?classCFileException@CFileExcepti
on@@
2UCRuntimeClass@@A) already defined in nafxcwd.lib(filex.obj)
    Searching H:\MSDEV\MFC\lib\mfcs40d.lib:
    Searching H:\MSDEV\LIB\msvcrtd.lib:
msvcrtd.lib(MSVCR40D.dll) : error LNK2005: ___threadhandle already
defined
in libcmtd.lib(tidtable.obj)

LINK : error : Internal error during Pass1
link.exe terminated at user request.
test2.exe - 5 error(s), 0 warning(s)
=== end linker output ===


This is my first foray with an MSVC version > 2.0, after a
couple of years of UNIX development. I have looked at the other
posts regarding this (or similar) problem(s), and tried the
suggestions - no success. I've also tried suggestions I found
in Books Online, shipped with MSVC, also no help. What am I
doing wrong? I hear that people actually *do* create apps
and make money using MSVC, right? I'm wondering how right now.

Sorry this post is long, but I believe in being thorough.

Please help.

Matthew Walker
0
Comment
Question by:matsaleh
1 Comment
 
LVL 4

Accepted Solution

by:
mbhakta earned 100 total points
ID: 1303139
This could be due to several reasons :
- Disk space .
- Clash between two libraries viz libc . libcmt or msvcrt.
- This could be also due to some corruption of obj files.

If the above things don't work tell me which version of VC++ are you running ?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 520
isEverywhere  challenge 19 86
twoTwo  challenge 35 114
post4 challenge 28 113
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question