Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

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

Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Norbert Irmer

I finally solved my problems.

 

I had 4 unresolved symbols.

 

3 were due to functions, which were declared  and defined with different signatures, e.g.

 

  Quantlib:: DefaultEvent:: DefaultSettlement::recoveryRate

 

 was declared in "QuantLib-1.0/ql/experimental/credit/defaultevent.hpp" as

 

   Real recoveryRate(Seniority sen) const;

 

while in "QuantLib-1.0/ql/experimental/credit/defaultevent.cpp"

 

  Real recoveryRate(const Seniority sen) const { … }

 

was defined.

 

The same problem i had with the constructors:

 

  QuantLib::FdmHestonSolver::FdmHestonSolver

  QuantLib::FdmHestonHullWhiteSolver:: FdmHestonHullWhiteSolver

 

They also had different declarations and definitions (parameters declared as non-const,

but const in definition).

 

 

The 4-th unresolved symbol was the template function,

 

   ForwardOptionArguments<QuantLib::Option::arguments>::validate

 

which was not instantiated, because the template definition (defined in

/pricingengines/forward/forwardengine.hpp) was not visible at the

instantiation location.

 

I simply added the line

 

  #include <ql/pricingengines/forward/forwardengine.hpp>

 

to

 

  QuantLib-1.0/ql/instruments/forwardvanillaoption.cpp

 

and the problem was gone.

 

 

As i previously wrote, when compiling Quantlib with Sunstudio i got

a lot of undefined "M_PI", "sqrt" etc..

I solved these by simply adding lots of "#include <math.h>" to the sources,

perhaps this could be done more elegantly at a central location.

 

But overall i can say QuantLib builds and runs fine on Solaris10/Sparc/Sunstudio12.1

with only minor modifications.

 

 

 

 

 

 

 

 


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Luigi Ballabio
On Fri, 2010-04-09 at 13:15 +0200, Norbert Irmer wrote:
> I finally solved my problems.
>
> I had 4 unresolved symbols.
>
> 3 were due to functions, which were declared  and defined with
> different signatures, e.g.

Ok, I'll fix those for next release.


> As i previously wrote, when compiling Quantlib with Sunstudio i got a
> lot of undefined "M_PI", "sqrt" etc..
>
> I solved these by simply adding lots of "#include <math.h>" to the
> sources, perhaps this could be done more elegantly at a central
> location.

Strange. Does adding '#include <cmath>' work instead?  Also, does the
compiler complain about 'sqrt' or 'std::sqrt'? May you send me the exact
message?

Finally, I'm not familiar with Sunstudio---is it just a set of compilers
or an IDE?  That is, do you run './configure' and 'make' or what?

Thanks,
        Luigi



--

Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away.
-- Antoine de Saint-Exupery



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Norbert Irmer
Sunstudio is an IDE plus compiler (successor of Sun-Forte, -WorkshopPro, or
whatever names, this product ever had:). The IDE uses NetBeans, and the
Debugging is very professional, reliable and robust on Sparc platforms
(like in Visual Studio, KDevelop+GCC+GDB cannot compare to this!).

At first I used ./configure. After the first problems, i installed "libtool"
and "automake" and recreated the configure script, but I still had the same problems.
Afterwards i used "cmake" (we are using this for our own projects too, much easier
to work with than automake!). I simply extracted the source files via a python
script from the Visual Studio project, and included them in the cmake project,
which simply looks like this:


  PROJECT( QuantLib CXX C )

  ADD_DEFINITIONS( -mt -library=stlport4 )
  SET( CMAKE_EXE_LINKER_FLAGS "-mt -library=stlport4" )

  INCLUDE_DIRECTORIES( /opt/diii_foreign/include /home/nir/tmp/original/QuantLib-1.0 )

  INCLUDE( sources.cmake )

  ADD_LIBRARY( QuantLib SHARED ${SOURCES} )

 
(if you are interested, i can send the project files / python script to you).



The first error message with unresolved math symbols is:

/opt/diii_foreign/bin/cmake -E cmake_progress_report /home/nir/tmp/original/QuantBuild/CMakeFiles
[  0%] Building CXX object CMakeFiles/QuantLib.dir/home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.o
/opt/sunstudio12.1/bin/CC   -DQuantLib_EXPORTS -KPIC -I/opt/diii_foreign/include -I/home/nir/tmp/original/QuantLib-1.0   -mt -library=stlport4 -o CMakeFiles/QuantLib.dir/home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.o -c /home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.cpp
"/home/nir/tmp/original/QuantLib-1.0/ql/math/array.hpp", line 593: Warning (Anachronism): Formal argument __x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double).
"/home/nir/tmp/original/QuantLib-1.0/ql/math/array.hpp", line 600: Warning (Anachronism): Formal argument __x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double).
"/home/nir/tmp/original/QuantLib-1.0/ql/math/array.hpp", line 607: Warning (Anachronism): Formal argument __x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double).
"/home/nir/tmp/original/QuantLib-1.0/ql/math/array.hpp", line 614: Warning (Anachronism): Formal argument __x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double).
"/home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.cpp", line 85: Error: M_PI is not defined.
"/home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.cpp", line 204: Error: M_PI is not defined.
"/home/nir/tmp/original/QuantLib-1.0/ql/math/distributions/bivariatenormaldistribution.cpp", line 239: Error: M_PI is not defined.
3 Error(s) and 4 Warning(s) detected.
*** Error code 3

The content of "bivariatenormaldistribution.cpp", line 85, is

    result = std::sqrt(1.0 - rho_*rho_)/M_PI*sum;


The problem with "sqrt" etc. seems to arise only, where these functions are used without the "std::"
modifier (I think <cmath> simply includes math.h in namespace std). To find one of those locations again,
I simply unpacked quantlib-1.0.tar.gz and defined M_PI, M_PI_2 and M_LN2 on the compiler command line
to get past the undefined constant errors. The first location I found was:

/opt/diii_foreign/bin/cmake -E cmake_progress_report /home/nir/tmp/original/QuantBuild/CMakeFiles
[  0%] Building CXX object CMakeFiles/QuantLib.dir/home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.o
/opt/sunstudio12.1/bin/CC   -DQuantLib_EXPORTS -KPIC -I/opt/diii_foreign/include -I/home/nir/tmp/original/QuantLib-1.0   -mt -library=stlport4 -DM_PI="3.14" -DM_PI_2="3.14/2.0" -DM_LN2="0.69" -o CMakeFiles/QuantLib.dir/home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.o -c /home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.cpp
"/home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.cpp", line 84: Error: The function "fabs" must have a prototype.
"/home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.cpp", line 151: Error: The function "abs" must have a prototype.
"/home/nir/tmp/original/QuantLib-1.0/ql/termstructures/inflation/seasonality.cpp", line 203: Error: The function "pow" must have a prototype.
3 Error(s) detected.
*** Error code 3



-----Ursprüngliche Nachricht-----
Von: Luigi Ballabio [mailto:[hidden email]]
Gesendet: Dienstag, 13. April 2010 11:09
An: Norbert Irmer
Cc: [hidden email]
Betreff: Re: [Quantlib-dev] Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

On Fri, 2010-04-09 at 13:15 +0200, Norbert Irmer wrote:
> I finally solved my problems.
>
> I had 4 unresolved symbols.
>
> 3 were due to functions, which were declared  and defined with
> different signatures, e.g.

Ok, I'll fix those for next release.


> As i previously wrote, when compiling Quantlib with Sunstudio i got a
> lot of undefined "M_PI", "sqrt" etc..
>
> I solved these by simply adding lots of "#include <math.h>" to the
> sources, perhaps this could be done more elegantly at a central
> location.

Strange. Does adding '#include <cmath>' work instead?  Also, does the
compiler complain about 'sqrt' or 'std::sqrt'? May you send me the exact
message?

Finally, I'm not familiar with Sunstudio---is it just a set of compilers
or an IDE?  That is, do you run './configure' and 'make' or what?

Thanks,
        Luigi



--

Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away.
-- Antoine de Saint-Exupery


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Luigi Ballabio
On Tue, 2010-04-13 at 15:51 +0200, Norbert Irmer wrote:
> Sunstudio is an IDE plus compiler (successor of Sun-Forte, -WorkshopPro, or
> whatever names, this product ever had:). The IDE uses NetBeans, and the
> Debugging is very professional, reliable and robust on Sparc platforms
> (like in Visual Studio, KDevelop+GCC+GDB cannot compare to this!).

Ok. Is there any #define that I can test for if I want to check whether
I'm using the Sun Studio compiler?  (as in, e.g., #ifdef __MINGW32__ to
check for the MinGW compiler.)

Thanks,
        Luigi


--

All generalizations are false, including this one.
-- Mark Twain



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Norbert Irmer
Yes, "__SUNPRO_CC", e.g.:


#ifdef __SUNPRO_CC
  #include <unistd.h>
#endif



-----Ursprüngliche Nachricht-----
Von: Luigi Ballabio [mailto:[hidden email]]
Gesendet: Mittwoch, 14. April 2010 11:51
An: Norbert Irmer
Cc: [hidden email]
Betreff: Re: AW: [Quantlib-dev] Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

On Tue, 2010-04-13 at 15:51 +0200, Norbert Irmer wrote:
> Sunstudio is an IDE plus compiler (successor of Sun-Forte, -WorkshopPro, or
> whatever names, this product ever had:). The IDE uses NetBeans, and the
> Debugging is very professional, reliable and robust on Sparc platforms
> (like in Visual Studio, KDevelop+GCC+GDB cannot compare to this!).

Ok. Is there any #define that I can test for if I want to check whether
I'm using the Sun Studio compiler?  (as in, e.g., #ifdef __MINGW32__ to
check for the MinGW compiler.)

Thanks,
        Luigi


--

All generalizations are false, including this one.
-- Mark Twain


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

Norbert Irmer
Hello,
I am checking your new version at the moment. Looks very good now,
but I still had 3 issues:

1.) There seems to be no "abs" for integral types in "ql/termstructures/inflation/seasonality.cpp".
The compiler complains:

Source:

Real MultiplicativePriceSeasonality::seasonalityFactor(const Date &to) const {

        Date from = seasonalityBaseDate();
        ....
            Integer diffDays = abs(to - from);  // in days

Error:

"/home/nir/tmp/unchecked/QuantLib-1.0.1/ql/termstructures/inflation/seasonality.cpp", line 151: Error: Overloading ambiguity between "std::abs(double)" and "std::abs(float)".
1 Error(s) detected.
*** Error code 1

I resolved this ambiguity by casting the operand to "double", so that it take std::abs(double):

            Integer diffDays = abs((double)(to - from));  // in days


2.) and 3.):

The compiler complains that the "operand--" must have a "lvalue" as an operand in
"ql/instruments/makecapfloor.cpp" and "ql/instruments/makeyoyinflationcapfloor.cpp".

Source (in "makecapfloor.cpp"):

      if (asOptionlet_ && leg.size() > 1)
                leg.erase(leg.begin(), --leg.end());
                 
Fix:

      if (asOptionlet_ && leg.size() > 1)
        {
                Leg::iterator tmp = leg.end();
                leg.erase(leg.begin(), --tmp);
        }




it looks very good now

-----Ursprüngliche Nachricht-----
Von: Luigi Ballabio [mailto:[hidden email]]
Gesendet: Mittwoch, 14. April 2010 17:55
An: Norbert Irmer
Betreff: ***UNCHECKED*** Re: AW: AW: AW: [Quantlib-dev] Quantlib with Sunstudio 12.1 on Solaris 2.10/Sparc

On Wed, 2010-04-14 at 17:48 +0200, Norbert Irmer wrote:
> Yes, would be nice.

Ok, please try the attached tarball.
Hopefully, it should compile without modifications.

Thanks,
        Luigi


--

Harrison's Postulate:
For every action, there is an equal and opposite criticism.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev