Re: QuantLib and Linux

Posted by eric ehlers on
URL: http://quantlib.414.s1.nabble.com/QuantLib-and-Linux-tp4393p4399.html

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
>