0

Getting below errors after compiling quantlib 1.9.2 with boost 1.5.4 on Fedora 20 with enable-sessions flag, and running one of the examples, any ideas?

       cd QuantLib-1.9.2/

        nohup ./configure --enable-sessions --enable-thread-safe-observer-pattern &
        tail -f nohup.out

        nohup make &
        tail -f nohup.out

        cp ql/.libs/libQuantLib.so.0.0.0  /lib64/libQuantLib.so
        cp ql/.libs/libQuantLib.so.0.0.0  /lib64/libQuantLib.so.0

        cd Examples/BermudanSwaption
        g++ BermudanSwaption.cpp -o BermudanSwaption -lQuantLib

        /usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/libQuantLib.so: 
undefined reference to `pthread_mutexattr_destroy'
undefined reference to `QuantLib::sessionId()'
undefined reference to `pthread_mutexattr_init'
undefined reference to `boost::system::system_category()'
undefined reference to `pthread_mutexattr_settype'
undefined reference to `boost::system::generic_category()'
     collect2: error: ld returned 1 exit status

Note: Im trying to enable sessions since getting segfault when quantlib is used in multi-threaded client application

alex
  • 1,757
  • 4
  • 21
  • 32

1 Answers1

1

answering my own question

1) the pthread and boost_system error disappeared after adding -lboost_system flag to compiler command line:

g++ BermudanSwaption.cpp -o BermudanSwaption -lQuantLib -lboost_system

this helped: undefined reference to boost::system::system_category() when compiling

2) to solve sessionId error I added sessionId function in BermudanSwaption.cpp as suggested here under QL_ENABLE_SESSIONS: https://github.com/lballabio/QuantLib/blob/master/ql/userconfig.hpp

"You will have to provide and link with the library a sessionId() function in namespace QuantLib, returning a different session id for each session"

after I commented out #if defined(QL_ENABLE_SESSIONS) in BermudanSwaption.cpp it compiled without errors:

//#if defined(QL_ENABLE_SESSIONS)
namespace QuantLib {

    Integer sessionId() { return 0; }

}
//#endif
alex
  • 1,757
  • 4
  • 21
  • 32