Re: Using QuantLib-SWIG 1.6 x64 for C# in Debug mode
Posted by
grantathon on
URL: http://quantlib.414.s1.nabble.com/TypeInitializationException-with-QuantLib-SWIG-1-6-x64-for-C-tp16732p16733.html
Hi Luigi,
I've recently figured out how to build and run QuantLib-SWIG x64 under Release and Debug mode for C# using the Visual Studio C++ 2013 (vc120) compiler. I realized that not only do the include and library directory paths must be correct for both Boost and QuantLib, but those two applications must also have their output DLLs placed in appropriate directories. After I better reorganized these locations to separate x64/x86 for Release and Debub mode, I was successful in running all versions in VS 2013. Honestly, I'm not 100% sure this was the final push to provide me with a valid build, but after repeating the process laid out below I have been able to run it fine. Below are the work instructions I followed.
- Download Boost, QuantLib, and QuantLib-SWIG
- Build Boost in 64-bit through the command line (see http://www.boost.org/doc/libs/1_58_0/more/getting_started/windows.html)
- Also, see first result from http://stackoverflow.com/questions/2322255/64-bit-version-of-boost-for-64-bit-windows, and replace --toolset=msvc-9.0 with --toolset=msvc-12.0 (or appropriate msvc version)
- Open a QuantLib solution
- In Property Manager->QuantLib, add main boost directory (e.g., C:\boost\boost_1_58_0) to VC++ Directories->Include Directories and add boost library directory (e.g., C:\boost\boost_1_58_0\lib\<platform>\lib, where platform is either Win32 or x64) to VC++ Directories->Library Directories
- In regards to the platform option for the library path, the appropriate path needs to be set for all Microsoft.Cpp.Win32.user and Microsoft.Cpp.x64.user settings
- Open QuantLib->Properties, and under Configuration Properties->General with Configuration set to "All Configurations" and Platform set to "All Platforms" set Output Directory to ".\lib\$(Platform)\" and Intermediate Directory to ".\build\$(qlCompilerTag)\$(Platform)\$(Configuration)\", if not already done so
- Set the Active Solution Platform in the Configuration Manager to x64
- Build the QuantLib project under both Release and Debug mode
- Add to your system environmental variables QL_DIR and set it to the QuantLib installation directory (e.g., C:\QuantLib-1.6)
- Under QuantLib-SWIG C# installation directory, run swig.cmd
- Open a QuantLib-SWIG C# solution
- In Property Manager->NQuantLibc,
add QuantLib library directory (e.g.,
C:\QuantLib-1.6\lib\<platform>", where platform is either
Win32 or x64) to Linker->Additional Library Directories
- Open NQuantLibc->Properties, and under Configuration
Properties->General with Configuration set to "All Configurations"
and Platform set to "All Platforms" set Output Directory to
"bin\$(qlCompilerTag)\$(Platform)\$(Configuration)\" and Intermediate Directory to
"build\$(qlCompilerTag)\$(Platform)\$(Configuration)\", if not already
done so
- Open NQuantLib->Properties, and under Build->Output with Configuration set to "Release"
and Platform set to "x64" set Output Path to
"bin\x64\Release\", if not already done so, and, if you want, repeat for all setting combinations of Configuration and Platform
- Set the Active Solution Platform in the Configuration Manager to x64
- Build the NQuantLib project under both Release and Debug mode
To test whether or not this process produced for you valid 64-bit DLLs, run the BermudanSwaption and EquityOption projects provided in the QuantLib-SWIG solution. Before doing this, be sure that the NQuantLibc and NQuantLib DLLs are correctly referenced in Properties->Build Events->Pre-Build Event Command Line. Mine look like
copy "$(SolutionDir)cpp\bin\$(qlCompilerTag)\$(Platform)\$(ConfigurationName)\NQuantLibc.dll" "$(TargetDir)"
copy "$(SolutionDir)csharp\bin\$(Platform)\$(ConfigurationName)\NQuantLib.dll" "$(TargetDir)"
Maybe you could attempt this as well and see if you achieve the same results. Also, there be some settings that I forgot to mention that might lead to unsuccessful builds. Either way, I will post a more descriptive answer to the thread I created in quantlib-users.
Best,
Grant
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users