Re: Errors compiling

Posted by Dirk Eddelbuettel on
URL: http://quantlib.414.s1.nabble.com/Errors-compiling-tp4684p4685.html

On 31 March 2006 at 22:59, J S wrote:
| Hi Luigi:
| I reinstalled Quantil (v 3.12) and make and make install worked
| without errors. However, when I make a test file only including the
| #include <ql/quantlib.hpp> line, I get huge chunk of nasty errors.
| What gives?!
|
| Thanks again.
|
| [root@furnace cprogs]# cat test.cpp
| #include <ql/quantlib.hpp>
| [root@furnace cprogs]# g++ test.cpp
| /usr/lib/gcc/i386-redhat-linux/4.0.2/../../../crt1.o(.text+0x18): In
| function `_start':
| : undefined reference to `main'
| /tmp/ccUfqbhw.o(.gnu.linkonce.r._ZTVN8QuantLib17DiscretizedOptionE[vtable
| for QuantLib::DiscretizedOption]+0x1c): undefined reference to
| `QuantLib::DiscretizedOption::postAdjustValuesImpl()'

You're cheating -- it's not yet April 1 in your timezone either!  

Seriously, here's a hint: Next time you wrestle with the compiler, look more
closely, and if everything else fails, consider reading some documentation.

What you have here is neither

   a) a valid program [ as it has no main() as g++ clearly tells you right
      at the very top of its output ] and

   b) is invoked incorrectly [ as you add QL headers but not the library,
      and again, the compiler and linker tell you, albeit cryptically ]

Try this instead:

edd@basebud:~> cat /tmp/q.cc
#include <ql/quantlib.hpp>
int main(void) { }
edd@basebud:~> g++ -Wall /tmp/q.cc -o /tmp/q -lQuantLib
edd@basebud:~> ls -l /tmp/q
-rwxr-xr-x  1 edd edd 360646 Mar 31 23:46 /tmp/q
edd@basebud:~> /tmp/q
edd@basebud:~>                                                  

The -Wall adds warnings which is often valuable.

Good luck,  Dirk

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