how to compile a program that uses quantlib

Posted by mariav on
URL: http://quantlib.414.s1.nabble.com/how-to-compile-a-program-that-uses-quantlib-tp12154.html

I wrote an extremely simple c++ program, but I cannot compile it. The program is the following:

#include <ql/quantlib.hpp>
#include <iostream>

using namespace QuantLib;

int main()
{
 std::cout << "Hello world!" << std::endl;
return 0;
}

if I compile using
g++ filename.cpp -o filename

I get the error messages:
  error: ql/quantlib.hpp: No such file or directory
 'Quantlib' is not a namespace-name
  expected namespace-name before ';' token

By doing an investigation on this forum (and on the internet) I read that I should compile using

g++ filename.cpp -o filename -l/path/to/includefiles -L/path/to/libfiles -lql

However, I have no idea what is the path to include and the path to the library files. That is, I understand that in the above line I have to replace /path/to/includefile to the path that applies to my installation (the same for /path/to/libfiles). However, how can I find that? I have no idea of what to type there.

In other forum response I found I only need to use
g++ filename.cpp -o filename -lQuantLib

That does not work. I get the same errors that I obtain if I do not add the -lQuantLib

My installation of Quantlib was done in the following way: I created a subdirectory called Quantlib in my
home directory and extracted the files QuantLib-0.9.0 to there. I went to the QuantLib-0.9.0 directory (home/maria/Quantlib/QuantLib-0.9.0/ ) and typed

./configure --with-boost-include=/home/maria/Boost/boost_1_35_0 --with-boost-lib=/home/maria/Boost/boost_1_35_0/libs

make

So, what should I type in order to compile my simple program?  THANKS!