Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 181
bobThere java chalenge 45 92
ffmpeg - "rtsp://...... Operation not permitted" 4 80
Unix Command -- Challenging  question 7 90
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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