Feb 18, 2012

Cgal /clr

Trying to use Cgal in a C++ project with Common Language Runtime support (/clr) you may encounter a few problems.

First ...

If the following message appears when you start your application:

The application failed to initialize properly (0xc000007b).

The problem may be due to Boost.Thread, which is required by Cgal.

According to

http://lists.boost.org/Archives/boost/2009/04/151043.php

modify

$BOOST_ROOT/libs/thread/src/win32/tss_pe.cpp

in this way:


#if (_MSC_VER >= 1400)
//#pragma section(".CRT$XIU",long,read)
#pragma section(".CRT$XCU",long,read)
#pragma section(".CRT$XTU",long,read)
#pragma section(".CRT$XLC",long,read)
        __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback;
        //__declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare;
        __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init;
        __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term;
#else

The __declspec lines were added in order to close this ticket (Severity - Cosmetic):

https://svn.boost.org/trac/boost/ticket/2199

Second ...

If the following assertion message appears at runtime:

Wrong rounding: did you forget the -frounding-math option if you use GCC (or -fp-model strict for Intel)?

Define CGAL_DISABLE_ROUNDING_MATH_CHECK and rebuild your project.

However, you should have seen this compiler warning:

warning C4996: '_controlfp_s': Direct floating point control is not supported or reliable from within managed code.

_controlfp_s is used directly by Cgal but, from MSDN:

This function is deprecated when compiling with /clr (Common Language Runtime Compilation) or /clr:pure because the common language runtime only supports the default floating-point precision.

So you should not expect identical results if you run the same project compiled with or without Common Language Runtime support.

Notes

Tested with Visual Studio 2010 using Cgal 3.9 and Boost 1.49.0 beta 1, x86 build, on Windows XP.

No comments:

Post a Comment

Note: Comments are moderated.