Opened 11 years ago

Closed 10 years ago

Last modified 7 years ago

#6695 closed Bugs (wontfix)

config/auto_link.hpp #errors unnecessarily errors when mixing /RTC and release CRTs

Reported by: Ben Craig <ben.craig@…> Owned by: John Maddock
Milestone: Boost 1.50.0 Component: config
Version: Boost 1.46.1 Severity: Problem
Keywords: Cc:

Description

config/auto_link.hpp has the following code: #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

This prevents builds that would otherwise succeed. The attached program uses the program_options and system libraries. If I remove these checks, I can build, link, and run it with the following invocations of Visual Studio 2003's cl.exe and link.exe, with no warnings or errors:

cl.exe /c /Foauto_link_test.obj /W3 /GR /GX /Od /MD /RTC1 /DDEBUG /I<boost include path> auto_link_test.cpp link.exe /subsystem:console /LIBPATH:<boost lib path> /OUT:auto_link_test.exe auto_link_test.obj

When the flags are present, I hit the previously mentioned #error.

In my company's local version of boost 1.46.1, I have removed this check with no issues. We build the boost libraries and our code with Visual Studio 2003 (i386), Visual Studio 2005 (i386 and x64), Visual Studio 2008 (i386 and x64) and Visual Studio 2010 (i386 and x64).

My proposed fix is to remove these checks entirely. If there are specific libraries that genuinely won't work with /RTC and a debug runtime, then this check could be moved to those library headers.

Attachments (1)

auto_link_test.cpp (1.2 KB ) - added by Ben Craig <ben.craig@…> 11 years ago.

Download all attachments as: .zip

Change History (4)

by Ben Craig <ben.craig@…>, 11 years ago

Attachment: auto_link_test.cpp added

comment:1 by John Maddock, 10 years ago

Resolution: wontfix
Status: newclosed

None the less, you're not supposed to mix /RTC with release builds, MSDN says:

"If you compile your program at the command line using any of the /RTC compiler options, any pragma optimize instructions in your code will silently fail. This is because run-time error checks are not valid in a release (optimized) build.

"You should use /RTC for development builds; /RTC should not be used for a retail build. /RTC cannot be used with compiler optimizations (/O Options (Optimize Code)). A program image built with /RTC will be slightly larger and slightly slower than an image built with /Od (up to 5 percent slower than an /Od build)."

I don't doubt that some libraries and programs link OK using this combination, but I've also seen linker errors because the release runtimes don't contain all the debugging functions that /RTC code may call - sorry don't recall the details right now.

So my inclination is to continue to disallow this, and let folks that really want to try this to do so at their own risk by modifying the source locally.

in reply to:  1 comment:2 by Dulantha Fernando, 7 years ago

Replying to johnmaddock:

None the less, you're not supposed to mix /RTC with release builds, MSDN says:

But then why is the /RTC1 option included as a command line argument when I build boost in release mode?

comment:3 by John Maddock, 7 years ago

But then why is the /RTC1 option included as a command line argument when I build boost in release mode?

That's news to me, and I'm unable to reproduce here. How are you building Boost?

Note: See TracTickets for help on using tickets.