ObjectARX 2015 debug configuration and boost

ObjectARX 2015 debug configuration and boost

Anonymous
Not applicable
1,594 Views
5 Replies
Message 1 of 6

ObjectARX 2015 debug configuration and boost

Anonymous
Not applicable

Hi, I don't really understand why I shouldn't use _DEBUG preprocessor macro in my debug configuration. Without this, boost gives me errors (auto_link.hpp):

//
// error check:
//
#if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
#  pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
#  pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
#  error "Incompatible build options"
#endif

So I need to do some hacking like:

 

//<-- BOOST HACK!
#ifndef NDEBUG
	#define _DEBUG
#endif
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/signals.hpp>
#include <boost/cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/shared_ptr.hpp>
#ifdef _DEBUG
	#undef _DEBUG
#endif
//BOOST HACK -->//

But I'm afraid that sooner or later something will go wrong. My boost version is 1.52. Anyone can help?

0 Likes
Accepted solutions (1)
1,595 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Despite of that hack, boost gives me linker errors:

 

libboost_signals-vc110-mt-gd-1_52.lib(connection.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(connection.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(trackable.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(trackable.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(slot.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(slot.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(named_slot_map.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(named_slot_map.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(signal_base.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in AppManager.obj
1>libboost_signals-vc110-mt-gd-1_52.lib(signal_base.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in AppManager.obj
1>     Creating library ...
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

0 Likes
Message 3 of 6

tbrammer
Advisor
Advisor

Using _DEBUG in your project configurations preprocessor defines can cause several DEBUG-libraries to be linked in your module.

As an example look into afx.h:

 

		#ifdef _DEBUG
			#pragma comment(lib, "afxnmcdd.lib")
		#else
			#pragma comment(lib, "afxnmcd.lib")
		#endif

Since you don't have a Debug-version of AutoCAD you cannot use modules linked with those Debug-Libs!

The common way to get around this is to include all relevant headers in stdafx.h and enclose the includes like this:

 

#if defined (_DEBUG) && !defined(DEBUG_AUTOCAD)
	#define DEBUG_WAS_DEFINED
	#undef  _DEBUG
#endif

... do all your includes here ...
#include <afx***.h>
#include <boost/smart_ptr/shared_ptr.hpp>

#ifdef DEBUG_WAS_DEFINED
	#define   _DEBUG
#endif

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 4 of 6

Anonymous
Not applicable

That's not the issue. One more time.

 

When I try to compile debug version (without _DEBUG macro - default for Autocad), boost throws compiler error:

"Using the /RTC option without specifying a debug runtime will lead to linker errors
Hint: go to the code generation options and switch to one of the debugging runtimes"

 

The boost code is:

#if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)

So, it means that I have to have _DEBUG macro defined for boost. But not for Autocad. So I tried to do a little hack - see ma first post here. But then during linking time, boost hacked me - see the second post. So now I can't see any way to do this. Your suggestion doesn't work, because boost NEEDS _DEBUG macro.

 

0 Likes
Message 5 of 6

tbrammer
Advisor
Advisor
Accepted solution

OK. I see.

You have to do what the pragma says: Disable the /RTC compiler option.

In your project settings-->C/C++-->Code generation turn the "runtime type check" options off so that all /RTC options are gone. __MSVC_RUNTIME_CHECKS will not longer be defined then. See here.

I use a german version of visual studio. Translated to english the settings are called

  • "Check smaller types" (set to "No")   and
  • "Complete runtime check" (set to "Standard").

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 6

Anonymous
Not applicable
Yes, that worked. Thank You 🙂
0 Likes