通过SWIG编译Quantlib为C# [英] Compiling Quantlib via SWIG for C#

查看:327
本文介绍了通过SWIG编译Quantlib为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人有任何使用经验痛饮?我目前正在研究 QuantLib ,看到C#code可以使用痛饮生成。我们正在探索的选项来创建的使用QuantLib和专有闭源库(这很可能会提供为净DLL)的金融功能组合库。这样做是为了结合这两种以创建统一的超级库。我见过QuantLib 的净口,但它似乎并不积极维护(而不是完全肯定多少实际移植),所以我避免它。

Anyone have any experience using SWIG? I am currently researching QuantLib and saw that C# code can be generated using SWIG. We are exploring options to create a combined library of financial functions using QuantLib and a proprietary closed source library (which will probably be made available as .Net dlls). The idea is to combine both of these to create a unified super library. I have seen the .Net port of QuantLib, but it seems that it is not actively maintained (and not entirely sure of how much was actually ported), so I am avoiding it.

的该步骤1是在制造可以用于'的任何地方即MS办公应用(经由VBA)图书馆,控制台应用程序以及服务器端(如:网络应用)来评价的难度。我认为这涉及到COM互操作,但我不知道从哪里开始,或者如果我甚至在正确的轨道。

Step 1 of this is to evaluate the difficulty in producing a library that can be used 'anywhere' i.e. MS office applications ( via VBA), console apps as well server-side (eg web apps). I assume that this involves COM Interop, but I have no clue where to start or if I am even on the right track.

我和C ++的经验;和COM是我发呆的东西(目前一个时髦词对我来说)。我知道与此主题相关的MSDN文章。

I have no experience with C++; and COM is something (a buzzword to me at the moment) that I have glazed over. I am aware of the relevant MSDN articles related to this topic.

我大意如下寻求帮助:


  1. 是否有替代品在C#中使用QuantLib?

  2. 对于我的发展环境,将我需要什么?

  3. 有谁知道夜风通过编制一个随时可以使用的QuantLib C#库? (一等奖=我的工作更少)

任何帮助AP preciated?

Any help appreciated?

编辑:我已经接受了我的答案是正确的,除非有一个更好的提供

I have accepted my answer as the correct one unless there is a better one provided.

推荐答案

所以它似乎对于SWIG的C#绑定可用。人们需要浏览 SVN库或列表在SouceForge文件来找到他们。

So it would seem that the C# bindings for SWIG are available. One needs to browse the SVN repository or list of files on SouceForge to find them.

该SWIG文件夹中包含几个子文件,这取决于您选择的语言,在我的情况的C#是我感兴趣的人。您需要先下载痛饮,它可执行文件系统 PATH 变量。

The SWIG folder contains several subfolders, depending on your language of choice, in my case C# was the one that interested me. You will need to download SWIG first and it the executable to system PATH variable.

请务必阅读的Readme.txt ,因为它包含了 QL_DIR 环境变量,也需要细节创建。

Make sure to read the Readme.txt as it contains details about the QL_DIR environment variable that also needs to be created.

这可能是VS防爆preSS的限制 - 但解决方案文件包含了C#项目和C ++项目,其中仅采用了C#或C ++部分可以随时打开。我的建议是创建单独的解决方案文件的C ++和C#项目。

This may be a limitation of VS Express - but the solution file contains both the C# project and C++ project, of which only either the C# or C++ portions can be opened at any time. My suggestion would be to created separate solution files for the C++ and the C# projects.

从.NET的背景下,LIB文件,OBJ文件和C ++相关联的所有其他爵士即将需要一些时间来让用途。

Coming from a .Net background, lib files, obj files and the all the other jazz associated with c++ takes some time to getting use to.


  1. 下载QuantLib和Boost描述这里

  2. 下载的焦油球<一个href=\"http://quantlib.svn.sourceforge.net/viewvc/quantlib/trunk/QuantLib-SWIG/?sortby=dateBlockquote\"相对=nofollow> QuantLib-痛饮从SourceForge 的文件夹中。 修改有一个<一个href=\"http://sourceforge.net/projects/quantlib/files/QuantLib/1.0/bindings/QuantLib-SWIG-1.0.zip/download\"相对=nofollow>的zip 的可供下载的主页上。其子文件夹中列出。检查在绑定的V1.0文件夹

  3. 运行位于 QuantLib-痛饮的 swig.cmd 文件\\ CSHARP 文件夹(你需要先下载痛饮() - >此产生CS封装文件Quantlib

  4. 生成C ++项目 NQuantLibc - 注意这里创建的DLL需要与NQuantlib C#创建的DLL始终发货。它需要被放置在由的DllImport 属性读取的位置。 (请参见动态链接库搜索顺序MSDN 的位置列表)

  5. 生成C#项目 NQuantLib

  1. Download QuantLib and Boost as described here
  2. Download the tar ball of the QuantLib-SWIG folder from SourceForge. There is a download of the zip available on the home page. Its listed within the subfolders. Check the v1.0 folders under Bindings
  3. Run the swig.cmd file located in QuantLib-SWIG\CSharp folder (you need to download SWIG first() --> this generates the cs wrapper files for Quantlib.
  4. Build the c++ project NQuantLibc - note the dll created here needs to be always shipped with the NQuantlib C# built dll. It needs to be placed in a location that is readable by the DLLImport attribute. (See Dynamic-Link Library Search Order on MSDN for list of locations)
  5. Build the C# project NQuantLib

对于我的发展环境,有什么会我需要?
<击>
似乎QuantLib当前版本只建立与VS 2008年已经有一些改变,VS 2010这会导致一些问题与编译。 C#的项目建立正常,但是只记得从V4更改目标框架V3.5降低。

With respect to my development environment, what would I need? It seems that the current version of QuantLib only builds with VS 2008. There have been some changes to VS 2010 which causes some issues with compilation. The C# project builds fine, however just remember to change the Target Framework from v4 to v3.5 to lower.

注:写这篇文章的时候有一个与 QL_HEX_VERSION 在C ++ SWIG项目的源文件数量的问题。运行后的 swig.cmd 打开VS项目,并更改344行 quantlib_wrap.cpp

Note: As the time of writing this there was an issue with the QL_HEX_VERSION number in the source files of the C++ SWIG project. After running the swig.cmd open the VS project, and change Line 344 of quantlib_wrap.cpp to

#if QL_HEX_VERSION < 0x010001f0//0x010100f0

我已经通过电子邮件发送该项目的作者,并等待反馈。 修改路易吉,正确地告诉我,这是在SVN的code(我使用)的任何问题。他建议,<一个href=\"http://sourceforge.net/projects/quantlib/files/QuantLib/1.0/bindings/QuantLib-SWIG-1.0.zip/download\"相对=nofollow> QuantLib-SWI​​G-1.0.zip 绑定应该使用。

I have emailed the project author, and awaiting feedback. Luigi, correctly informed me that this is any issue with the code in SVN (which I used). He suggested that the QuantLib-SWIG-1.0.zip bindings should be used.

Quantlib也建立在 VC ++ 2010 的最新版本。

Quantlib also build on VC++ 2010 with the latest release.

这篇关于通过SWIG编译Quantlib为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆