开发者

Exposing Quantlib and another library to C# via SWIG

开发者 https://www.devze.com 2023-02-15 10:16 出处:网络
Compiling and linking Quantlib takes some time, as it is not a small project. I am building some additional functionality on top of Quantlib, and I want to keep this additional functionality in a sepa

Compiling and linking Quantlib takes some time, as it is not a small project. I am building some additional functionality on top of Quantlib, and I want to keep this additional functionality in a separate project.

Is there a way to easily expose two C++ projects into one library via SWIG? Because my project is quite small, just a few classes, I can easily afford to do manually what SWIG automates. However, I really want to deploy to my users only the bare minimum of files, that is the two dlls that are built by开发者_如何学Python Quantlib-SWIG.


I don't know Quantlib in particular, but generally, doing this with SWIG should be quite straightforward: the C# module of SWIG supports the dllimport option which allows you to specify the DLL referenced for the P/Invoke methods (refer to the C# section of the SWIG manual for details).

Thus, you can just create a separate SWIG interface file for your extension, set dllimport to the name used by Quantlib, and compile both C++ glue code files into a single DLL for both Quantlib and your own code.


Take a look at Resolver Systems' pre-built binaries of QuantLib with C# bindings although I am unsure how frequently they keep it up to date with QuantLib releases.

It will save you having to worry about one of your libraries at least?

0

精彩评论

暂无评论...
验证码 换一张
取 消