QuantLib and Linux

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

QuantLib and Linux

L.Isella
Dear All,
I am new fairly new to C++ and Linux.
I am currently using Ubuntu (a Debian-based distribution).
I installed the QuantLib library (I can run the test-suite from the command line), so everything should be fine.
However, if I try to add to a simple Hello World program the line

#include <ql/quantlib.hpp>

I get plenty of errors.

I also tried Luigi's suggestion to compile DiscreteHedging.cp

g++ DiscreteHedging.cpp -lQuantLib

but I was not better off.

I am sure this is completely trivial and that anyone with Debian could help.
I just need to find out how to get g++ to "see" the library.
 As soon as I can get something running, I will try to use the QuantLib library inside Anjuta (Gnome C++ IDE), but that is another story.
Many thanks

Lorenzo



Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

eric ehlers
Hi Lorenzo,

I suspect that you've uncompressed and compiled QuantLib, but haven't
yet run 'make install' ?

When you just uncompress and compile QuantLib, client apps within the
QuantLib directory tree automatically know where to find QuantLib,
this is why you are able to run test-suite.  If you do 'make examples'
you should also find that the example programs compile and run.

In order to link QuantLib to projects external to the QuantLib
directory tree - such as your Hello World program - you must first
install QuantLib by issuing 'make install'.  By default 'make install'
installs the QuantLib headers and libs to some standard location (e.g.
/usr/local) which will automatically be picked up by g++.  (You need
to issue 'make install' as root in order to install QuantLib to the
default location).

Alternatively you can install QuantLib to some other location by
re-running configure with the --prefix flag e.g...

    ./configure --prefix=$HOME/QuantLib

... then issuing 'make install'.

In that case when compiling your client app you need to tell the
preprocessor where to find the QuantLib header files e.g.

    g++ -I$HOME/QuantLib -c -o helloworld.o helloworld.cpp

And when linking your app you need to tell the linker where to find
the QuantLib lib file e.g.

    g++ -o helloworld helloworld.o -L$HOME/QuantLib/lib -lQuantLib

And before executing your program you need to tell the loader to
search the nonstandard location e.g.

    export LD_LIBRARY_PATH=$HOME/QuantLib/lib
    helloworld

Regards,
Eric

On 1/22/06, L.Isella <[hidden email]> wrote:

> Dear All,
> I am new fairly new to C++ and Linux.
> I am currently using Ubuntu (a Debian-based distribution).
> I installed the QuantLib library (I can run the test-suite from the command line), so everything should be fine.
> However, if I try to add to a simple Hello World program the line
>
> #include <ql/quantlib.hpp>
>
> I get plenty of errors.
>
> I also tried Luigi's suggestion to compile DiscreteHedging.cp
>
> g++ DiscreteHedging.cpp -lQuantLib
>
> but I was not better off.
>
> I am sure this is completely trivial and that anyone with Debian could help.
> I just need to find out how to get g++ to "see" the library.
>  As soon as I can get something running, I will try to use the QuantLib library inside Anjuta (Gnome C++ IDE), but that is another story.
> Many thanks
>
> Lorenzo
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> <a href="http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

Luigi Ballabio
In reply to this post by L.Isella
On Jan 22, 2006, at 12:45 PM, L.Isella wrote:
> I am currently using Ubuntu (a Debian-based distribution).
> I installed the QuantLib library (I can run the test-suite from the
> command line), so everything should be fine.
> However, if I try to add to a simple Hello World program the line
>
> #include <ql/quantlib.hpp>
>
> I get plenty of errors.

What kind of errors? If g++ complains that it cannot find the QuantLib
include files, it might be that your compiler is not set to look into
/usr/local/include (that's where the headers are installed by default
when you run "make install".) You can add such directory to your
include path by adding "-I/usr/local/include" to your command line.

Later,
        Luigi



Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

Dirk Eddelbuettel
In reply to this post by L.Isella
On 22 January 2006 at 11:45, L.Isella wrote:
| Dear All,
| I am new fairly new to C++ and Linux.
| I am currently using Ubuntu (a Debian-based distribution).

Which version of Ubuntu?  Which version of QuantLib did that give you?

| I installed the QuantLib library (I can run the test-suite from the command=
|  line), so everything should be fine.
| However, if I try to add to a simple Hello World program the line
|
| #include <ql/quantlib.hpp>
|
| I get plenty of errors.

You need to install the libquantlib0-dev package as well.  

Being able to execute binaries is necessary but not sufficient to compiling
your own.

Dirk

--
Hell, there are no rules here - we're trying to accomplish something.
                                                  -- Thomas A. Edison


Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

L.Isella
In reply to this post by L.Isella
On Sun, 2006-01-22 at 11:06 -0600, Dirk Eddelbuettel wrote:
On 22 January 2006 at 11:45, L.Isella wrote:
> | Dear All,
> | I am new fairly new to C++ and Linux.
> | I am currently using Ubuntu (a Debian-based distribution).
>
> Which version of Ubuntu?  Which version of QuantLib did that give you?
> I am on Ubuntu 5.10 (Breezy). I am using version 0.3.9 of the QuantLib library (to be precise: libquantlib0-dev version 0.3.9-6ubuntu3).
I installed everything which had something to do with the quantlib, so I do not think there is anything missing.
 



> | I installed the QuantLib library (I can run the test-suite from the command=
> |  line), so everything should be fine.
> | However, if I try to add to a simple Hello World program the line
> |
> | #include <ql/quantlib.hpp>
> |
> | I get plenty of errors.
>
> You need to install the libquantlib0-dev package as well.  
>
Which I did.

Being able to execute binaries is necessary but not sufficient to compiling
> your own.
>
> Dirk
>
Alright, I see the point you and the others are trying to make.
I thought apt-get would take care of everything as usual, whereas, if I am getting it right, I should compile the library myself.
Is it difficult? I just need a few commands to type to get this lib working.

Many thanks

Lorenzo






Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

Dirk Eddelbuettel
On 22 January 2006 at 19:33, L.Isella wrote:
| On Sun, 2006-01-22 at 11:06 -0600, Dirk Eddelbuettel wrote:
| On 22 January 2006 at 11:45, L.Isella wrote:
| > | Dear All,
| > | I am new fairly new to C++ and Linux.
| > | I am currently using Ubuntu (a Debian-based distribution).
| >
| > Which version of Ubuntu?  Which version of QuantLib did that give you?
| > I am on Ubuntu 5.10 (Breezy). I am using version 0.3.9 of the QuantLib
| > library (to be precise: libquantlib0-dev version 0.3.9-6ubuntu3).

Ok, same here on my Kubuntu (== Ubuntu with KDE instead of Gnome) box.

[...]

| > You need to install the libquantlib0-dev package as well.  
| >
| Which I did.

Ok, then you have to show us what you did, and what errors you got. We can't
guess that.

[ Ok I just tried it, and there is an implicit Depends: on the -dev package
for the Boost headers. So also do 'apt-get install libboost-test-dev' and the
you should be set. ]

So try this:

0. Prelims:  
        Besides libquantlib0-dev, you need quantlib-examples for the
        source code of the examples. I presume you have that.

1. Get source code, copy to /tmp and gunzip
        $ cd /usr/share/doc/libquantlib-0.3.9c2/examples/
        $ cp -a DiscreteHedging/ /tmp/
        $ cd /tmp/DiscreteHedging/
       
2. Build it:
        $ g++ -o DH DiscreteHedging.cpp -lQuantLib

3. You should have a new executable 'DH':
        edd@joe:/tmp/DiscreteHedging$ ls -l DH
        -rwxr-xr-x  1 edd edd 523030 2006-01-22 14:09 DH

4. Run it:
        edd@joe:/tmp/DiscreteHedging$ ./DH
Option value: 2.51207

        |        | P&L          |  P&L    | Derman&Kamal | P&L          | P&L
samples | trades | Mean         | Std Dev | Formula      | skewness     | kurt.
-------------------------------------------------------------------------------
50000   | 21     | -0.000       | 0.43    | 0.44         | -0.35        | 1.59
50000   | 84     | -0.001       | 0.22    | 0.22         | -0.20        | 1.76



| Being able to execute binaries is necessary but not sufficient to compiling
| > your own.
| >
| > Dirk
| >
| Alright, I see the point you and the others are trying to make.
| I thought apt-get would take care of everything as usual, whereas, if I am
| getting it right, I should compile the library myself.

No, I don't think anybody suggested that. You should be able to get started
with the Debian / Ubuntu packages.

Arguably, you found a minor bug in that the libquantlib0-dev package should
probably also pull in the libboost-test-dev package. I will add that.

Hope this helps,   Dirk

--
Hell, there are no rules here - we're trying to accomplish something.
                                                  -- Thomas A. Edison


Reply | Threaded
Open this post in threaded view
|

Re: QuantLib and Linux

L.Isella
In reply to this post by L.Isella
Ok, same here on my Kubuntu (== Ubuntu with KDE instead of Gnome) box.
>
> [...]
>

> Ok, then you have to show us what you did, and what errors you got. We can't
> guess that.
>
> [ Ok I just tried it, and there is an implicit Depends: on the -dev package
> for the Boost headers. So also do 'apt-get install libboost-test-dev' and the
> you should be set. ]
>
> So try this:
>
> 0. Prelims:  
> Besides libquantlib0-dev, you need quantlib-examples for the
> source code of the examples. I presume you have that.
>
> 1. Get source code, copy to /tmp and gunzip
> $ cd /usr/share/doc/libquantlib-0.3.9c2/examples/
> $ cp -a DiscreteHedging/ /tmp/
> $ cd /tmp/DiscreteHedging/
>
> 2. Build it:
> $ g++ -o DH DiscreteHedging.cpp -lQuantLib
>
> 3. You should have a new executable 'DH':
> edd@joe:/tmp/DiscreteHedging$ ls -l DH
> -rwxr-xr-x  1 edd edd 523030 2006-01-22 14:09 DH
>
> 4. Run it:
> edd@joe:/tmp/DiscreteHedging$ ./DH
> Option value: 2.51207
>
>         |        | P&L          |  P&L    | Derman&Kamal | P&L          | P&L
> samples | trades | Mean         | Std Dev | Formula      | skewness     | kurt.
> -------------------------------------------------------------------------------
> 50000   | 21     | -0.000       | 0.43    | 0.44         | -0.35        | 1.59
> 50000   | 84     | -0.001       | 0.22    | 0.22         | -0.20        | 1.76
>
                                                                           
Thanks Dirk.
Well, now things seem to be much better. I replicated step by step what you did and I got the same as you (well, same option value and different parameters in the table, but I suppose it is normal (probably the results do not converge yet)).
I'll be doing more tests in the next days, but I suppose the problem was the Boost headers, which turned out not to be installed when I had run apt-get the first time.
Sorry for taking up your time on such a trivial issue.
Best regards

Lorenzo