Solved

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

Posted on 1997-08-05
1
824 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

688 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