QuantLib in CLR - visual-c++

I use VS2012 (VC11), Boost 1.57, QuantLib 1.4. My goal is to make a Visual CLR project using these libraries in a separate solution than the original QuantLib solution. I started step-by-step to carefully include the libraries, but when I just added the line #include , it gave me the following error:
metadata operation failed (8013119F) : A TypeRef exists which should,
but does not, have a corresponding TypeDef : (OPERATORS_NOT_ALLOWED): (0x0100001b)
Anyone can help?

Related

Boost thread library version mismatch

I've created a managed C++ log parser application using C++ vectors and Winforms. I want to add multithreading and Boost seemed like a better option than Winforms BackgroundWorker because I want to be able to execute my existing C++ function with each thread. I installed Boost multiple times following multiple different tutorials (lastly this one: https://levelup.gitconnected.com/the-definite-guide-on-compiling-and-linking-boost-c-libraries-for-visual-studio-projects-c79464d7282d) and I still have the same issue when I try to #include <boost/thread.hpp>
Error LNK1104 cannot open file 'libboost_thread-vc143-mt-x64-1_78.lib'
I don't know why it's looking for this library when I have Boost 1_79 installed not 1_78. My .lib file also has "mt-gd-x64" not just "mt-x64". I've already specified the correct file path to the library in Project->Properties->Linker->General->Additional Library Directories. I've also tried installing Boost via Visual Studio 2022 NuGet Package Manager. The lib file in that folder is also slightly off. "vc120" instead of "vc143". I've even tried changing the .lib file name to match the file name in the linker error exactly but when I do that I get more errors like LNK1104 cannot open file 'libboost_chrono-vc143-mt-x64-1_78.lib'
Do I just need to delete all my Boost files and download version 1_78 and try again? Why is Visual Studio looking for the wrong file name when it compiles? Is my #include statement wrong?
I ended up solving this problem by downloading boost 1_78, building it, and specifying that folder instead or the 1_79 folder. If anyone might know why the program was looking for 1_78 instead of 1_79 feel free to respond Also big thanks to George Gkasdrogkas who wrote the tutorial that worked best for me on how to install Boost. Tutorial is linked in the question :)

Building MicroSIP 3.19.18: "PJRPID_ACTIVITY_ON_THE_PHONE" not defined

I am trying to build a custom modified version of the
MicroSIP softphone.
Before any modifications, I can't build the version 3.19.18 using VisualStudio 2017.
I am able to compile successfully the previous minor version: 3.18.5
The error is:
1>c:\users\xxxxxxxxx\microsip\maindlg.cpp(1038): error C2065: 'PJRPID_ACTIVITY_ON_THE_PHONE': undeclared identifier
If I look at the code that uses that identifier I come across this, that is new in 3.19:
case PJSUA_BUDDY_STATUS_ONLINE:
if (buddy_info.rpid.activity == PJRPID_ACTIVITY_ON_THE_PHONE) {
image = MSIP_CONTACT_ICON_ON_THE_PHONE;
if (PjToStr(&buddy_info.status_text).Left(4) == _T("Ring")) {
ringing = true;
If I look at the type of "buddy_info.rpid.activity" it's of type "pjrpid_activity" That is defined in "rpid.h" from the SIP library "pjsip" :
typedef enum pjrpid_activity
{
/** Activity is unknown. The activity would then be conceived
* in the "note" field.
*/
PJRPID_ACTIVITY_UNKNOWN,
/** The person is away */
PJRPID_ACTIVITY_AWAY,
/** The person is busy */
PJRPID_ACTIVITY_BUSY
} pjrpid_activity;
No 'PJRPID_ACTIVITY_ON_THE_PHONE' defined here. And that string can't be found anywhere else on that project.
This enum is part of the Open Source project pjsip which is currently on version 2.9.
I tried to look back into earlier versions to find out if that enum evolved and had the correct elements. No luck.
It looks like they are using a modified version of the pjsip library, but I can't find a link, a mention or anything that would help me to find out what is that missing dependency.
More than that, MicroSIP.org will charge you $95 to obtain a customized version including "source code and assistance with compilation if needed".
Of course it is needed if they keep secret the dependencies.
Anyway, MicroSIP is statically linked to the unknown pjsip library variant.
Microsip and PJSIP are both licensed under the GPLv2.
My question is: How to find out my missing dependency?
Are they required to disclose that information?
Does anyone know about a fork of pjsip that would be the one I am looking for?
Better, Has anyone been able to somehow compile MicroSIP, ver >= 3.19.0?
To build any distribution of Microsip, you should build pjsip first. Therefore you should set some source and library paths for the Microsip project. Then you can build cleanly. It may be that some library is missing like opus, etc... and you may need to find the current version of these and build them beforehand as well.
I came to see that you must be having different platform toolset for MicroSIP and PjProject. Try to build it from starting using the same build tool and platform toolset for the both of your project, it will automatically clear several issues.

moving a threaded application from c++ to CLR

I have a fairly simple, multithreaded application that runs as a console app in c++, based mostly on calling external dlls. I need to add a Form to it, so I have created a new visual studio project (c++/CLR), and am adding my existing cpp and .h files to it. BUT, when I try to build, i get:
Severity Code Description Project File Line Suppression State
Error C1189 #error: <thread> is not supported when compiling with /clr or /clr:pure.
Severity Code Description Project File Line Suppression State
Error (active) #error directive: <mutex> is not supported when compiling with /clr or /clr:pure.
IS this how I should be adding a form? How can I get around this error?
Thanks.
Ah, solved. As here:
VC2008, how to turn CLR flag off for individual files in C++/CLI project
I need to turn off clr support on the single .cpp file.

Cannot Compile OpenCV 2.4.5 with VS 2013 RTM

Has anyone had any luck compiling openCV with VS 2013 RTM? I have tried and get a bunch of "min doesn't belong to namespace std" "max doesn't belong to namespace std" in the IlmImf module, and opencv_features2d doesn't compile with the following error:
opencv\modules\core\include\opencv2/core/core.hpp(4512): fatal error C1075: end of file found before the left brace '{' at '......\modules\features2d\src\features2d_init.cpp(187)' was matched
Since the latest CMake UI doesn't yet support building with 2013 (at least from the UI and I'm a noob), my process was configuring CMake for 2012, and then opening the generated solution with 2013 and upgrading the compiler to vc12.
I was able to get past the min/max errors by adding header includes for in the 'offending' files, but I am stumped by the full error I posted above.
Thanks
Update:
The accepted answer provides what is necessary to compile OpenCV in 32-bit debug and release, and 64-bit debug, but now the compiler fails to compile 64-bit release due to an internal compiler error. This is likely the compiler's fault at this point, but the answer is still solves many problems.
Update 2:
So the 64-bit issue turned out to be a bug in the auto-vectorizer. Here is the corresponding workaround.
Hi, thanks for the great bug report. I confirm this is a bug in the compiler optimizer. We will fix it in a future release.
If you need a source code workaround, please turn the vectorizer off on the loop inside computeOrbDescriptor:
#pragma loop(no_vector)
for (int i = 0; i < dsize; ++i)
{
**...**
That lets me build orb.cpp & stardetector.cpp.
If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance. For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.
I am closing this MSConnect item. Feel free to respond if you need anything else.
Thanks,
Eric Brumer - Microsoft Visual C++ Team
The connect bug can be found here. Unfortunately the real fix for this is postponed until a later date.
I've managed to compile OpenCV 2.4.6 on VS2013 RC, but initially it had the same errors as in question.
I've opened VS solution and fixed all error in two steps:
1) Replaced (Ctrl+H)
#include \<string\>
to
#include <algorithm>\n#include <string>
in entire solution (be sure to enable RegExp in replace dialog)
2) In "modules/opencv_features2d/Src/features2d_init.cpp" changed line 184 to:
obj.info()->addParam(obj, "detector", (Ptr<Algorithm>&) obj.detector);
(search for "GridAdaptedFeatureDetector" in this file for other OpenCV versions)
For the first issue:
http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx
It is explicitly called out:
You must #include <algorithm> when calling std::min() or std::max().
Before due to the internal implementation of the VC++ libraries <string> would pull in these functions.
Please see http://code.opencv.org/issues/3273 for more information on the internal compiler error issue.

Call Boost libraries in C++

I have built the Boost library from these instructions:
http://stackoverflow.com/questions/3529163/install-boost-library-in-visual-c-2008
Directory of the unzipped Boost folder is C:\Users\David\Desktop\boost_1_44_0. I have called Visual C++ 2010. How to use Boost in a program?
I mean I want the following.
#include<boost>
Tweak your project properties to add C:\Users\David\Desktop\boost_1_44_0 to the include path and maybe the link path if you plan to use the part of Boost that is not include-only (libboost_filesystem for instance).
You have to include the header path and library path in your project.
Also #include <boost> won't do anything. You have to include each individual feature of boost that you need. For instance if you need to link to the filesystem.lib file in to boost directory, and use #include "boost/filesystem.hpp".
Take a look at this answer from step 6: Another Answer

Resources