Solved

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

Posted on 1997-08-05
1
817 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now