This post was updated on .
Hi I've got a little problem
I'm calling the quantlib library compiled as a shared library on Linux ( using the -fPIC option ) in a java wrapper. So, the code calling the ql lib is into a java function. My code crash with some memory allocation problem ( hard to know coz I don't have each time the message ) when I want to define a calendar : Calendar calendar = UnitedStates(); On the other hand this : Calendar calendar = NullCalendar(); is working I've got a glibc detected malloc() memory corrupt ... and I've the same thing with DayCounter dDayCounter = ActualActual(ActualActual::ISDA); but OneDayCounter() is working Does anybd has an idea ? Could it come from boots ? Thanks Pierre |
Hi Pierre, Your example is unclear to me. If it's java, then I think you may be not constructing the objects correctly. Below is a java code fragment and its output which I'm able to build and run. If you supply a simple example I can see if I can get it to run. You will likely need to look in the swig .i files to understand how to translate from the c++ into java. Regards, Tito. -- In java, I'm able to say: DayCounter dayCounter = new Actual365Fixed(); System.out.println(dayCounter); DayCounter actualAct = new ActualActual(); System.out.println(actualAct); Calendar calendar = new TARGET(); System.out.println(calendar); Calendar us = new UnitedStates(); System.out.println(us); And I get output: Actual/365 (Fixed) day counter Actual/Actual (ISDA) day counter TARGET calendar US settlement calendar moloko <[hidden email]> wrote:
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Tito,
Thanks for your response. Sorry I was not clear enough. Mainly coz I'm not comfortable with the java stuff involved in my code... ( an old version is already running nd I need to adapt the code with a new QL version ) So, I'm using the QL lib in a file that will generate a lib used by java. As I understand the code, it is a C++ code that will be called in java, a wrapper... I've got #include <jni.h> and JNIEXPORT jboolean JNICALL Java_com_ffm_marketData_calculation_QuantLibCalculation_ (JNIEnv *env, jobject obj, jstring logFileName, jint max_days, jintArray or_array){ and inside the function I'm calling "Calendar calendar = UnitedStates();" and other QL functions. DayCounter dDayCounter = ActualActual(ActualActual::ISDA); is not working but DayCounter dayCountConvention = Actual360(); do Pierre
|
In reply to this post by moloko
I experienced a problem very similar to yours when I was trying to use
the swig wrapped version of QuantLib in Python. DayCounter() was working but ActualActual(ActualActual::ISDA) completely froze my python console, probably due to a memory leak. After few tries I realized that in QuantLib-SWIG/setup.py I was including boost_1_34_1 but I was linking against an older version of boost. Setting the right library linking flag(boost_1_34_1) solved my problem. Hope this help. N.Jean ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by moloko
On Wed, 2008-02-06 at 00:45 -0800, moloko wrote:
> I've got > #include <jni.h> > > and > JNIEXPORT jboolean JNICALL > Java_com_ffm_marketData_calculation_QuantLibCalculation_ > (JNIEnv *env, jobject obj, jstring logFileName, jint max_days, jintArray > or_array){ > > and inside the function > I'm calling "Calendar calendar = UnitedStates();" and other QL functions. Pierre, are you allowed to post the code of your function? If not, maybe you might strip it down to a simpler version that still triggers the error, but doesn't give away any proprietary stuff? Later, Luigi -- So little done, so much to do. -- Cecil Rhodes ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
I first would like to know if it's coming from JNI or from my QL installation. That's why I've open anoer post about it gcc -Wall -I/usr/local/include/ql -o test.o -c test.cpp gcc -o test -L/usr/local/lib -lQuantLib test.o ./test: error while loading shared libraries: libQuantLib-0.8.1.so: cannot open shared object file: No such file or directory here is the test.cpp code -------------------------------------- // the only header you need to use QuantLib #define BOOST_LIB_DIAGNOSTIC # include <ql/quantlib.hpp> #undef BOOST_LIB_DIAGNOSTIC #ifdef BOOST_MSVC /* Uncomment the following lines to unmask floating-point exceptions. Warning: unpredictable results can arise... See http://www.wilmott.com/messageview.cfm?catid=10&threadid=9481 Is there anyone with a definitive word about this? */ // #include <float.h> // namespace { unsigned int u = _controlfp(_EM_INEXACT, _MCW_EM); } #endif #include <boost/timer.hpp> #include <fstream> #include <iostream> #include <iomanip> using namespace QuantLib; using namespace std; #if defined(QL_ENABLE_SESSIONS) namespace QuantLib { Integer sessionId() { return 0; } } #endif int main(int, char* []) { FILE * File; File = fopen ("toto.txt","w"); Calendar calendar = UnitedStates(); fclose (File); return 1; } ----------------------------------- About my JNI function, the problem is it's too connected my all my processes. Btw, I've re-installed the boost library and I've still the problem. I think if first I'm able to run my test file, it will be a big step for me ( I've no problem with test.cpp with VC Express ) Pierre
|
Hi,
So, I've been able to run my simple test file which does not use JNI ( only QuantLib ), thanks to Luigi. So now, I gonna try to be more precise about my main issue: I've got a cpp file which is calling QL functions and JNI to produce functions in a library called in a java process. I need to update our QuantLib version from 0.3.4 to 0.8.1. The problem is that my java process crash at runtime. I've tried to isolate the line responsible for that crash I've got 2 types Calendar calendar = UnitedStates(); and DayCounter dayCounter = Thirty360(Thirty360::European); but Calendar calendar = TARGET() do not lead to crash and neither DayCounter dayCounter = Actual360(); I've copy-pasted the cpp file ------------------------------------- #include <ql/quantlib.hpp> #include <jni.h> #include "QuantLibCalculation.h" using namespace QuantLib; JNIEXPORT jboolean JNICALL toto (){ Calendar calendar = UnitedStates(); //DayCounter dayCounter = Thirty360(Thirty360::European); return JNI_TRUE; } ------------------------------------- here is the command line I use to compile : g++ -o libFTXQuantLib.o -shared -I/usr/java/jdk_1.5.0_11/include -I/usr/java/jdk_1.5.0_11/include/linux -lQuantLib QuantLibCalculationNEW.cpp -fPIC If someone can help... Pierre |
On Thu, 2008-02-14 at 08:40 -0800, moloko wrote:
> So, I've been able to run my simple test file which does not use JNI ( only > QuantLib ), thanks to Luigi. > So now, I gonna try to be more precise about my main issue: > > I've got a cpp file which is calling QL functions and JNI to produce > functions in a library called in a java process. > I need to update our QuantLib version from 0.3.4 to 0.8.1. > > The problem is that my java process crash at runtime. > I've tried to isolate the line responsible for that crash > I've copy-pasted the cpp file > ------------------------------------- > #include <ql/quantlib.hpp> > #include <jni.h> > #include "QuantLibCalculation.h" > > using namespace QuantLib; > > JNIEXPORT jboolean JNICALL toto > (){ > > Calendar calendar = UnitedStates(); > //DayCounter dayCounter = Thirty360(Thirty360::European); > > > return JNI_TRUE; > } > ------------------------------------- > here is the command line I use to compile : > g++ -o libFTXQuantLib.o -shared -I/usr/java/jdk_1.5.0_11/include > -I/usr/java/jdk_1.5.0_11/include/linux -lQuantLib QuantLibCalculationNEW.cpp > -fPIC Pierre, are you sure the linker is not picking up the old 0.3.4 library? Did you uninstall it, or is it still there somewhere? Luigi -- It is better to know some of the questions than all of the answers. -- James Thurber ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The old QL lib has been erased, as the old boost libs.
Another thing I have just tried ldd on my library and it looks like it doesn't find the QL lib. My LD_LIBRARY_PATH is set to /usr/local/lib ( but not /etc/ld.so.conf ) and the QL lib exist Pierre Selon Luigi Ballabio <[hidden email]>: > On Thu, 2008-02-14 at 08:40 -0800, moloko wrote: > > So, I've been able to run my simple test file which does not use JNI ( only > > QuantLib ), thanks to Luigi. > > So now, I gonna try to be more precise about my main issue: > > > > I've got a cpp file which is calling QL functions and JNI to produce > > functions in a library called in a java process. > > I need to update our QuantLib version from 0.3.4 to 0.8.1. > > > > The problem is that my java process crash at runtime. > > I've tried to isolate the line responsible for that crash > > > I've copy-pasted the cpp file > > ------------------------------------- > > #include <ql/quantlib.hpp> > > #include <jni.h> > > #include "QuantLibCalculation.h" > > > > using namespace QuantLib; > > > > JNIEXPORT jboolean JNICALL toto > > (){ > > > > Calendar calendar = UnitedStates(); > > //DayCounter dayCounter = Thirty360(Thirty360::European); > > > > > > return JNI_TRUE; > > } > > ------------------------------------- > > here is the command line I use to compile : > > g++ -o libFTXQuantLib.o -shared -I/usr/java/jdk_1.5.0_11/include > > -I/usr/java/jdk_1.5.0_11/include/linux -lQuantLib > QuantLibCalculationNEW.cpp > > -fPIC > > Pierre, > are you sure the linker is not picking up the old 0.3.4 library? Did > you uninstall it, or is it still there somewhere? > > Luigi > > > -- > > It is better to know some of the questions than all of the answers. > -- James Thurber > > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
This post was updated on .
In reply to this post by moloko
All,
I've isolated my code from my system and I can send sources files to generate the crash. If anybody could have a look at it, I will deeply appreciate If it's working on your machine, it will definitely say that I've got a problem on my server. If it's not working it will say that I'm not building the library the right way. to remember the problem : I'm building a shared lib which is a mix of JNI / QuantLib I call this lib in a java process I've got a crash when I call Calendar calendar = TARGET(); but not Calendar calendar = NullCalendar(); or DayCounter dayCounter = Thirty360(Thirty360::European); but not DayCounter dayCounter = Actual360(); Regards, Pierre test_quantlib test_quantlib_make_so TestQuantlib.class TestQuantlib.cpp TestQuantlib.h TestQuantlib.java file list description TestQuantlib.cppTestQuantlib.java -- java source code to load "libTestQuantLib.so" into JVM, and contains JNI native method. TestQuantlib.class -- the class file compiled from TestQuantlib.java TestQuantlib.cpp -- testing jni cpp file which implement the native method defined in TestQuantlib.java TestQuantlib.h -- header file generated for the native java method. test_quantlib_make_so -- script to build "libTestQuantLib.so" test_quantlib -- script to launch JVM testjin.log -- log file generated for the testing from TestQuantlib.cpp. |
Pierre, The problem is almost certainly your installation/environment. I was able to build and run the c++ test case you posted on feb 8th without issue (and had sent you an email affirming as much on the 11th). I suggest you rebuild your environment and verify that you can run the provided examples. I'm pretty sure that once you have a clean environment you will see that your test case works fine. As for the java aspect of it, I'm not quite clear on why you'd write your own jni interfaces when the provided swig interfaces work well. You might want to try them when you have a clean install so you can determine if you want to proceed with the roll-your-own jni approach or use the swig interfaces going forward. Regards, Tito. moloko <[hidden email]> wrote:
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Tito,
Yes, thanks for your help about the cpp file ( ld.so.conf not well configured ). The reason why we are doing this way with JNI is mainly historical: the program has been done 5 years ago... we wanted to update the QL version in a smooth way. Of course, if we cannot solve this problem, we'll use the SWIG java interfaces . Regards, Pierre Selon Tito Ingargiola <[hidden email]>: > > Pierre, > > The problem is almost certainly your installation/environment. I was able > to build and run the c++ test case you posted on feb 8th without issue (and > had sent you an email affirming as much on the 11th). I suggest you rebuild > your environment and verify that you can run the provided examples. I'm > pretty sure that once you have a clean environment you will see that your > test case works fine. > > As for the java aspect of it, I'm not quite clear on why you'd write your own > jni interfaces when the provided swig interfaces work well. You might want > to try them when you have a clean install so you can determine if you want to > proceed with the roll-your-own jni approach or use the swig interfaces going > forward. > > Regards, > > Tito. > > > moloko <[hidden email]> wrote: > All, > > I've isolated my code from my system and I can send sources files to > generate the crash. > If anybody could have a look at it, please tell me, and I will send the > files. > > to remember the problem : > I'm building a shared lib which is a mix of JMI / QuantLib > I call this lib in a java process > I've got a crash when I call > Calendar calendar = TARGET(); > but not > Calendar calendar = NullCalendar(); > or > DayCounter dayCounter = Thirty360(Thirty360::European); > but not > DayCounter dayCounter = Actual360(); > > I have also made a post about building a "pure" QuantLib shared library > > Regards, > > Pierre > -- > View this message in context: > > Sent from the quantlib-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Nicola Jean
Hi, N.Jean:
I worked with Pierre these days to try to solve this issue. Thanks for your suggestion "Setting the right library linking flag(boost_1_34_1) ". I added " -I/usr/local/include/boost-1_34_1 " option when build shared library, and it works! Lingyun Shi
|
This post was updated on .
All,
So, unfortunately, the problem is now with another structure: boost::shared_ptr<RateHelper> depositRateHelper(new DepositRateHelper( The files to update in the set of files : TestQuantlib.cpp test_quantlib_make_so If someone has some time to launch the scripts, it will help a lot ! Regards, Pierre |
On Thu, 2008-02-21 at 06:22 -0800, moloko wrote:
> So, unfortunately, the problem is now with another structure: > boost::shared_ptr<RateHelper> depositRateHelper(new DepositRateHelper( Pierre, what is the problem now? Does it compile? Does it give any error message when it runs? (You can check by catching any exceptions and printing the message, as in: try { boost::shared_ptr<RateHelper> depositRateHelper(...); } catch (std::exception& e) { std::cout << e.what() << std::endl; } Luigi -- Green's Law of Debate: Anything is possible if you don't know what you're talking about. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
I'm already triing to catch the exception, but my console freeze try{ boost::shared_ptr<RateHelper> depositRateHelper(new DepositRateHelper( Handle<Quote> (depositRateQuote),term,2,calendar ,BdConv ,true,2,dayCounter) ); } catch(std::exception& e){ std::cout << "Prblm depositratehelper: " << e.what() << std::endl; return JNI_FALSE; } If you have some time to try the sample I've sent and updated on the mailling list Anyway, we will try to make a sample with the SWIG interface, but I think we have the same kind of problem as it's still using JNI, isn't it ? Regards Pierre Selon Luigi Ballabio <[hidden email]>: > On Thu, 2008-02-21 at 06:22 -0800, moloko wrote: > > So, unfortunately, the problem is now with another structure: > > boost::shared_ptr<RateHelper> depositRateHelper(new DepositRateHelper( > > Pierre, > what is the problem now? Does it compile? Does it give any error > message when it runs? (You can check by catching any exceptions and > printing the message, as in: > > try { > boost::shared_ptr<RateHelper> depositRateHelper(...); > } catch (std::exception& e) { > std::cout << e.what() << std::endl; > } > > Luigi > > > -- > > Green's Law of Debate: > Anything is possible if you don't know what you're talking about. > > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Luigi Ballabio
Hi again,
I think this time the problem is definitely solved. I was able to have my sample code running by re-installing the QL lib after having erased some boost lib file in /lib and etc dir. Apparently those files are installed by default with the RedHat package and it caused some confusion Anyway thanks, and I'll post the new developped methods I've talked about s ome time ago Pierre Selon Luigi Ballabio <[hidden email]>: > On Thu, 2008-02-21 at 06:22 -0800, moloko wrote: > > So, unfortunately, the problem is now with another structure: > > boost::shared_ptr<RateHelper> depositRateHelper(new DepositRateHelper( > > Pierre, > what is the problem now? Does it compile? Does it give any error > message when it runs? (You can check by catching any exceptions and > printing the message, as in: > > try { > boost::shared_ptr<RateHelper> depositRateHelper(...); > } catch (std::exception& e) { > std::cout << e.what() << std::endl; > } > > Luigi > > > -- > > Green's Law of Debate: > Anything is possible if you don't know what you're talking about. > > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |