none
Fatal error while compiling a static library in Debug configuration. RRS feed

  • Question

  • hi,

         I have an VC++ application and I am creating a static library by taking few cpp files from that application. 

    I am getting this error while compiling in "debug":

    "fatal error C1189: #error :  You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently."

    Where as It is successfully compiling in "Release" mode.

    Visual Studio 2008

    Windows7(64Bit) OS.

    Looking for the help to fix this issue.

    Regards,

    Mayank


    Thanks & Regards, Mayank Agarwal

    Thursday, December 6, 2012 9:24 AM

Answers

  • First, make sure you are linking the debug version of your application with the debug version of your library.  Trying to use the release build of your static library in your debug application won't work.

    If you are doing that and still see the problem, try this:

    _DEBUG is typically defined in Project Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions.

    It sounds like some of your CPP files have _DEBUG defined and others don't. Usually you want all of your CPP files to have the same defines set up here.  Select each CPP file in your library and your project and make sure they all have _DEBUG defined.

    Thursday, December 6, 2012 3:18 PM

All replies

  • First, make sure you are linking the debug version of your application with the debug version of your library.  Trying to use the release build of your static library in your debug application won't work.

    If you are doing that and still see the problem, try this:

    _DEBUG is typically defined in Project Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions.

    It sounds like some of your CPP files have _DEBUG defined and others don't. Usually you want all of your CPP files to have the same defines set up here.  Select each CPP file in your library and your project and make sure they all have _DEBUG defined.

    Thursday, December 6, 2012 3:18 PM
  • Before i come to your actual question can you tell us why are you using static library why not dll. As error itself tells what is the actual problem. What you can do find All the project and look for them which basically using the release configuration and switch them to use the debug configuration.

    Thanks


    Rupesh Shukla

    Thursday, December 6, 2012 7:09 PM