How to set the environment variable QL_NET in Visual Studio 2010 for QuantLib+SWIG

StackOverflow https://stackoverflow.com/questions/9795755

  •  25-05-2021
  •  | 
  •  

Frage

I have a pre-compiled QuantLib+SWIG* project that I am using in C# to calculate options prices. I would like to add a class to QuantLib but I am having trouble creating the SWIG glue. After adding the class to my copy of the QuantLib source, I build the project fine in Visual Studio 2010. My problem is that I am having trouble getting my QuantLib+SWIG process to recognize my new class.

I am not sure how to set the QL_NET environment variable to the location of my QuantLib installation. Two questions:

  1. The QuantLib+SWIG project is a C# project. How do I set an environment variable within a C# project?

  2. What should the value of this environment variable be? Should it be the path to the QuantLib-vc100-mt.lib file? Or should it be the path to the Release folder? Or should it be some other path?

The README.txt file doesn't explain this issue:

Visual Studio .NET projects are provided; note that before launching the IDE, you'll have to define an environment variable QL_DIR whose value must equal the path to your QuantLib installation, e.g., "C:\Lib\QuantLib".


* I got the pre-compiled QuantLib+SWIG project from http://www.resolversystems.com/products/quantlib-binary/

In order to get this project to work, I had to include these lines in my C# code:

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);

SetDllDirectory(@"C:\Users\JRobinson\Desktop\Quantlib-Resolver\lib");
War es hilfreich?

Lösung

You don't have to set the environment variable from C# or visual studio. (For Windows 7) Right click on my Computer->Properties->Advance system settings -> Advanced -> Environment Variable

There create a new variable named (under System variables): QL_DIR and set the value to your installation library (which is may be this C:\Users\JRobinson\Desktop\Quantlib-Resolver\lib in your case)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top