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! |
On Sat, 2008-07-12 at 20:41 -0700, mariav wrote:
> I wrote an extremely simple c++ program, but I cannot compile it. > > 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 > 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 Hi Maria, as for most Linux programs, you also have to run 'make install' after 'make'. If you have administrator privileges on your computer, you can run 'make install' with your current configuration (or 'sudo make install' if you need to get the required privileges.) After that, g++ filename.cpp -o filename -lQuantLib should work. Otherwise, you can install in your user space: run first ./configure --with-boost-include=/home/maria/Boost/boost_1_35_0 --prefix=/home/maria/ (on one line, of course) and then 'make install'. The installation will create a few directories (include, lib, bin...) in your home directory; if you want them somewhere else, just provide a different prefix to configure. After this, you can use g++ filename.cpp -o filename -l/home/maria/include -L/home/maria/lib -lQuantLib (of course, replace /home/maria with the correct prefix if you chose a different one.) Luigi -- Any software problem can be solved by adding another layer of indirection. -- Steven M. Bellovin ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by mariav
Thank you, Luigi. That part worked after I followed your instructions. I have new errors now, but I work on my own for some time before posting a question to the forum. Thanks!
|
Free forum by Nabble | Edit this page |