how to debug QuantLib? - quantlib

I have installed QuantLib on Mac.
I also compiled the bermudaswaption successfully, as an example.
I tried to modify/debug the code of QuantLib like analyticeuropeanengine.cpp when code reviewing.
But when modifying the code like analyticeuropeanengine.cpp, I would need to re-make / install all the project, and that costs a lot of time.
How I can do this efficiently?

Related

VS Code can't step into linked library project

VS Code 1.48, Ubundu 18.04, cmake 3.10, gdb 8.1-ubuntu3.2, gcc 7.5.0.
VSC newb, ubuntu newb, unix experienced, cmake experienced, gdb newb, c++ grizzled vet. I'm mostly a windows guy, though I've dabbled with various flavors of Unix since college back in the early 90s. wheeze
I have two project directories loaded into my VSC workspace... both written in C++ with a dash of python hither and yon. The first, we'll call it Orc, works great. All it's tests pass, it's cmake-defined install ran just fine. Life is good.
The second project, we'll call Elf, builds fine, and works fine until it needs to depend on Orc, at which point I get a seg fault. Another call to that same library succeeded (the version check:trivial, no parameters), though I cannot step into that either. When it comes time to tell Orc to do some actual work: boom. I also haven't noticed any core dumps lying about to be interrogated.
(side question: where does VSC stash its core dumps?)
I made sure both projects are debug builds. They're both using the same version of Boost. I've succeeded in running all our unit tests in both Orc and Elf on windows.
What do I need to do to be able to step into Orc so I can see what's going wrong?
I added the following to my CMakeLists.txt and it seems to be happy. There's probably a better way to do it though.
if (UNIX)
add_definition(-ggdb)
endif()
Down side: Always adds -ggdb to Linux builds, including Release... not just the debug variants. Problems in with non-gdb debuggers.
I'm guessing there's a better way to specify a debug-only flag like this, but I'm not sure what that might be. I'm getting familiar with CMake, but I'm no expert.

Raspberry Pi crashes when building OpenFrameWorks project in Eclipse CDT

I'm working on a Raspberry Pi 3 with OS Raspbian Jessie. I'm using Eclipse CDT (for C/C++) and am trying to learn about OpenFrameWorks:
http://openframeworks.cc/
I installed everything according to the guides and imported everything to Eclipse. I thought it seemed to work out, but when I try to run some test-code I get the error "Unable to launch, binary not found." I look it up and find a potential solution, that I have to build the actual project first.
This is my problem, when I try to build the project Eclipse gets to about 20% and then the entire Raspberry freezes, forcing me to force a restart. How can I continue from here on out? I don't know if I still should try to build the project through Eclipse or if there is another way to actually run some test code for OpenFrameWorks.
I don't know if this is the best place to ask about this, but I'm thankful for all answers.
Eclipse is super slow on Raspberry Pi.
I recommend using the provided setup scripts to install dependencies. After you compile OF, use make files to compile projects.
In terms of editing code, I recommend using a light weight text editor (geany for example). I've tried CodeBlocks and Qt Creator, which are faster/less resource intensive than eclipse, but still pretty heavy for a system with limited resources.
Another option is to combine your computer the RPi:
Use projectGenerator to generate a project for both Raspberry Pi and your computer/IDE
Edit/test/iterate on your computer
When ready to run on RPi, sync the project using your preferred method(e.g. SSH/SFTP/git/etc.), then use make -j4(to use all 4 cores) in the RPi project folder.
The pro is you the quick compile/feedback times you're used to on your computer.
The con is this method won't work for RPi specific code (e.g. accessing GPIO, PiCamera, etc.)
Another option is to setup cross compilation, but getting everything ready is a bit laborious. (Although, once it's done, it saves time on the long run).

VSCode c++ configuring for vc toolchain

I'm trying to start a work in vscode , latest C++ plugin version supports ms debugger, so as I'm mostly working under windows it was a signal to try this.
c++ tools plugin from MS and cmake tools were installed.
my test project was however not built . the problem is clear , but I need an advice from experienced vscode users how to solve this right.
cmake doesn't see vc compiler.
(after using QtCreator) I expected that vscode could detect vc installation... however that's not so. ok, I have a two ways:
fill environment variables INCLUDE/LIB/PATH with a headers, libs and binaries
just run vcvarsall.bat x64
Second way is a simple and reliable. so final question is:
how to run .bat at the begining of vscode start?
(I don't mean write another bat/cmd, prepare the environment and run vscode inside the same script after that)
Although the question is fairly old, I'll try to give a useful answer, in case others stumble across, just like I did.
I believe what you are trying to achieve is not possible. Code inherits the environment it was started with. If you did not launch it from a developer command prompt, you will not be able build and debug. (Building might be possible if every task first starts the vcvarsall.bat, but that slows things down by a lot. Debugging I think will still not work.)
If you are willing to, you can check out vector-of-bools CMake Tools extension which does build automation as well as automatic MSVC detection. It builds using CMake (thus you need to write your build scripts using CMake), but it will take care of building just by pressing F7, like what most VS users are familiar with.

Porting from pcl-1.5 to pcl-1.7

I am using ubuntu14.04. I have a code which is written in pcl-1.5. I now want to run it in pcl-1.7. It's giving a lot of compilation errors.
Is there a way to port my classes and functions from pcl-1.5 to pcl-1.7?
I understand that you want to build your project on PCL 1.5 while PCL 1.7 is installed. This is possible. I assume you install PCL 1.5 from source and then build it so that it ends up with a build directory. These instructions are vague because it has been a while since I have done this but here they are: In the project you are trying to build (I am assuming you are using cmake), put something like the following line before the line find_package(PCL REQUIRED) (or the similar line that you have):
SET(PCL_DIR /path/to/pcl1.5/build CACHE LOCATION "Where the PCL version I want to use has been built to")
---Edit based on comment---
Okay, so it seems by PCL 1.5 code you mean code that you have previously written for PCL 1.5 and want to run with PCL 1.7. This should be possible but those with a good knowledge of the main differences between 1.5 and 1.7 probably will not have the time to answer this question. As such I suggest you check the errors as they come up during compilation and running and check the new API for the new way of doing things. It will be easier to locate the errors if you compile your project bit by bit. If you understand what the code is doing it will be easier also. That is all that I have.

OpenCV haartraining: Mergevec error: Input file does not exist or not readable

Following this tutorial, I've created my positive samples but need to merge them now, using mergevec. I downloaded the mergevec.exe binary file provided and got the two required dlls cxcore100.dll and highgui100.dll. However, when I run it like so:
mergevec samples.txt samples.vec
it gives me the error:
ERROR: Input file <filename> does not exist or not readable.
What should I do to fix this? My vec files are fine, because I was able to view them using the opencv_createsamples utility. So I know they're fine.
I ran into this issue as well and made a python utility that combines .vec files to avoid installing openCV again: https://github.com/wulfebw/mergevec
Hope it helps.
I was in the same situation as you few days ago so i'll try to help you out =P.
First of all i am interested to know where you found the mergevec.exe, because it isn't available to download anymore if i recall. I ask because i think that you might have downloaded an exe compiled on Linux. I had the same error when i tried to execute the mergevec, i had compiled on Ubuntu, on my Windows computer. Even with the 2 dlls.
As i explained it here , The mergevec from Naotoshi was originally made for Unix distribution, so under windows you will encounter a lot of problems. I first tried to do it on windows but i abandonned because it was too complicated and even with a full Cygwin installation i could not compile the mergevec.cpp.
What i advise you to do is to create yourself an Ubuntu virtual machine and to compile your own mergevec.exe. Once done you can copy your vec files in your virtual machine and merge them under Ubuntu. After this you can bring back the merged vec file to Windows if you want (It is better to not run the training under a VM: less computation power).
Here is what i did:
Installed VMware player with Ubuntu 14.0.4 (although i don't recommend it, still some bugs)
Installed OpenCV from the sources with TBB. There are a lot of tutorials, but the only one that worked for me is the OPenCV website, they are the more accurate on the libraries you mandatorily need.
I downloaded the GitHub classifier training and then I followed the commands given and it worked well.
If you encounter any library problem or OpenCV Installation issue don't hesitate i went through them too.