Solved

Problem linking object modules : DSTransformer.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE

Posted on 2004-08-03
3
1,115 Views
Last Modified: 2008-03-10
Can some on pl explain wht these errors are about ?
and how can I fix them ?
Code is in the one location and object is present in corresponding ...\Debug directory...

-------------------------------------------------------------------------------------------------------------------------------
DSXMLofstream.cpp
Generating Code...
Linking...
   Creating library Debug/DSAGAPI.lib and object Debug/DSAGAPI.exp
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
StdAfx.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE
DSTransformer.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE
DSView.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE
0
Comment
Question by:adgarcia13
  • 2
3 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11710929
Appears to be a project settings conflict. Maybe you have created a blank project and pasted some code from a different project?
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 11712667
The include file afx.h contains a sequence

#ifndef _AFX_NOFORCE_LIBS

...  include some windows and mfc libs

#ifdef _DLL
      #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "msvcrtd.lib")
      #else
            #pragma comment(lib, "msvcrt.lib")
      #endif
#else
#ifdef _MT
      #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "libcmtd.lib")
      #else
            #pragma comment(lib, "libcmt.lib")
      #endif
#else
      #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "libcd.lib")
      #else
            #pragma comment(lib, "libc.lib")
      #endif
#endif
#endif


// force inclusion of NOLIB.OBJ for /disallowlib directives
#pragma comment(linker, "/include:__afxForceEXCLUDE")

... some other stuff

#endif //!_AFX_NOFORCE_LIBS

You see that  msvcrtd.lib should be included as you have a DEBUG version but the error message above says there is a conflict with 'msvcrt.lib' the RELEASE version of the runtime library.

Maybe you removed _DEBUG macro from the preprocessor settings for Win32 Debug??

Regards, Alex






0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 11712685
The unresolved external is most likely a following error because of the wrong runtime library.

You should also check your Precompiled Header settings. When using stdafx.h as precompiled header file, all your cpp files that are not excluded from precompiled headers must have #include "stdafx.h" as first include statement.

Regards, Alex
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

757 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

18 Experts available now in Live!

Get 1:1 Help Now