@sheegaon This question is about a specific quant library. The user is asking about how to include a single function. So if anyone knows which header that specific function is in, it would be an existing user of said library.
–
chrisaycockAug 26 '11 at 1:43

1

Maybe it's worth posting a Community Wiki post on how to actually use QuantLib in a new project? Can we do Wiki posts here on QF SE?
–
Dmitri NesterukAug 26 '11 at 14:03

2

I think this question is absolutely on topic here as it is. It is about a specific problem with a specific quant lib - so it fits in well in my opinion.
–
vonjdAug 26 '11 at 17:43

2 Answers
2

The best way is to open the Visual Studio Command Prompt using a shortcut under Programs→Microsoft Visual Studio→Visual Studio Tools. Now, you need to navigate to the QuantLib folder inside the folder where you have QuantLib (there are other folders such as QuantLibXL – that’s not the one you need.

Now, compile the whole of QuantLib by running the following command: msbuild /t:Rebuild /p:Configuration=Release QuantLib_vc10.sln.

Inside this folder, if you look in the lib folder, you’ll get a lib file called QuantLib-vc<VER>-mt.lib and a corresponding file with a -gd suffix. You need these libs as well as the headers.

2. Configure headers

Right-click the project and choose Properties. Now, make sure you choose All Configurations in the configuration drop-down list box on the top-left of the window.
First, navigate to ConfigurationProperties→C/C++→General. In the Additional Include Directories, add the path to QuantLib’s directory. If you add the <QL Root>\QuantLib directory, you will be able to reference QuantLib headers with statements such as #include <ql/someheader.hpp>. If you did it correctly and you’re using VS2010, IntelliSense will kick in immediately, meaning if you type #include <ql/, VS will show you a helper list with headers (which is useful).

3. Configure library references

Now, navigate down to Configuration Properties→Linker→General. In the Additional Library Directories add the path to the QuantLib’s \lib directory.

Now move down to the Input header under the Linker header. Edit the Additional Dependencies field, prepending it with the name of the QuantLib library file — you need to specify the filename (without the full path) of the .lib file you need to include. The -mt.lib file is used for the Release build, and the -mt-gd.lib for the Debug build. If you mess these up, you'll get errors.

4. Run it

By now, assuming you have the boost libraries in your VS \include folder, the following should compile and run without problem: