Can't use external C++ libraries in Visual Studio - c++

I've been fighting with this for hours today - trying to run some simple code from a MatPlot++ library. The code is copied and pasted straight from their website. Every time I try to run the code (using VS community 2019) I get a series of errors:
Error (active) E1696 cannot open source file "matplot/matplot.h"
Error (active) E0725 name must be a namespace name
Error (active) E0020 identifier "pareto" is undefined
Error (active) E0020 identifier "title" is undefined
Error (active) E0020 identifier "show" is undefined
Error C1083 Cannot open include file: 'matplot/matplot.h': No such file or directory
Here's the code:
#include <cmath>
#include <matplot/matplot.h>
#include <random>
int main() {
using namespace matplot;
std::vector<double> codelines = { 200, 120, 555, 608, 1024, 101, 57, 687 };
std::vector<std::string> coders = { "Fred", "Ginger", "Norman", "Max",
"Julia", "Wally", "Heidi", "Pat" };
pareto(codelines, coders);
title("Lines of Code by Programmer");
show();
return 0;
}
I've installed the library using the exe installer, I've downloaded the source files and added their directory to the additional include directories. I've put the files inside the project directory, tried several variations of #include using different filepaths. Nothing is working.
The closest I've got is putting the library files into the project folder and changing it to use "" instead of <>. This got rid of the errors for the main matplot.h header file, but then it created errors saying that every single dependency was also missing, despite them all being within the same directory.
Please can someone help point out what I could be doing wrong here? I'm not used to using external libraries so its driving me crazy.

Related

I am encountering an error E0003 which says that the #include file includes itself

Everything was going perfect with the header file but the moment I updated visual studio it started giving me and error the moment I write
#include "std_lib_facilities.h"
The error pops up saying Severity Code Description Project File Line Suppression State
Error (active) E0003 #include file "C:\USERS\DHEERAJ\SOURCE\REPOS\PROJECT13\PROJECT13../../std_lib_facilities.h" includes itself Project13 C:\Users\Dheeraj\source\repos\std_lib_facilities.h 5
I dont know why this is happening can somebody please help.

How to add Open eVision library to a project in Microsoft Visual Studio for a C++ project

I am trying to run a sample C++ project in Microsoft Visual Studio 2019. The sample file is generated using Open eVision Studio
// This cpp script file was created by Open eVision Studio.
// Open eVision Studio (c)Euresys s.a. Belgium 2006.
// Date : 9/3/2020 at 10:37.
// This section contains the variable declarations
#include "Open_eVision_2_10.h"
using namespace Euresys::Open_eVision_2_10;
using namespace std;
EImageBW8 EBW8Image1; // EImageBW8 instance
EImageBW8 EBW8Image2; // EImageBW8 instance
EImageBW8 EBW8Image3; // EImageBW8 instance
// This section contains the operations code
try {
EBW8Image1.Load("C:\\Users\\Public\\Documents\\Euresys\\Open eVision 2.10\\Sample Images\\EasyMatch\\Switch1.tif");
EBW8Image2.Load("C:\\Users\\Public\\Documents\\Euresys\\Open eVision 2.10\\Sample Images\\EasyMatch\\Switch1.tif");
EBW8Image3.SetSize(512, 512);
// Make image black
EasyImage::Oper(EArithmeticLogicOperation_Copy, EBW8(0), &EBW8Image3);
EasyImage::Threshold(&EBW8Image2, &EBW8Image3, 85);
EasyImage::Threshold(&EBW8Image2, &EBW8Image3, 126);
EasyImage::Threshold(&EBW8Image2, &EBW8Image3, 139);
}
catch(const EException&){
// Insert exception handling code here
}
What I am trying to do is to run this in Microsoft Visual Studio 2019. I have created a C++ Desktop application and copy pasted the above code. In the project properties C/C++ -> General -> Additional include directories as C:\Program Files %28x86%29\Euresys\Open eVision 2.10\Include;
But error during build. Some of the error displayed.
Error (active) E1696 cannot open source file "Open_eVision_2_10.h" euresys_1
Error (active) E0276 name followed by '::' must be a class or namespace name euresys_1
Error C1083 Cannot open include file: 'Open_eVision_2_10.h': No such file or directory euresys_1
Error (active) E0020 identifier "EImageBW8" is undefined euresys_1
The screen shot

How to fix Cannot open source file: 'seal/util/config.h'

I am currently using VS studio 2019 and cloned from GIT MicrosoftSEAL using Visual Studio i am having problems making it run.
I already downloaded C++ packages along with SDK 10.0.16299.0 then retargetted the whole projects but still getting the 34 errors (1 E196 and 33 C0183) from a file called mscv.h which has the include line underlined
// Read in config.h
#include "seal/util/config.h"
Errors:
Error (active) E1696 cannot open source file "seal/util/config.h"
Error C1083 Cannot open include file: 'seal/util/config.h': No such file or directory

Visual C++ : XGBoost does not work when called from a DLL

I have a requirement to use XGBoost within a Visual C++ project DLL.
I have been able to download and build the XGBoost source using VC++ and CMake.
When I include the XGBoost code in a test console application, it works fine.
However, when I try to replicate what I've done with the console application in a DLL project, it won't compile.
I am struggling to even use a basic XGBoost type within the project.
I suspect the problem is my ignorance with DLL projects and would appreciate your help.
Here's what's happening in my DLL project:
When I use the following include as the very first line in a cpp class file, it compiles:
#include <xgboost\c_api.h>
With it compiling, if I try to use a simple type defined in this include file, the build fails with the following message:
...\dll_test\xgb_driver.cpp(20): error C2065: 'BoosterHandle': undeclared identifier
This is the line that causes the error:
BoosterHandle my_handle;
"BoosterHandle" is in fact defined in <xgboost\c_api.h>
When I put the include below any other include, I get the following error messages:
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C2146: syntax error: missing ';' before identifier 'bst_ulong'
Below is a little more information on what I did to get XGBoost working with a console app and how I created the DLL project.
=-=-=-=-=-=
Here's what I did to use XGBoost with a console. Everything about it seems to work. I've tested the model predictions, and they are
consistent with what I'm seeing in R.
Using the documentation found here:
https://xgboost.readthedocs.io/en/latest/build.html
I downloaded the XGBoost source and built it using CMake and Visual Studio 2015.
Under Project > Linker > Input > Additional Dependencies,
I added the xgboost.lib file
Under Project > Linker > General > Additional Library Directories
I added a reference to ...\xgboost\build\Release
Under Project > VC++ Directories > Include Directories
I added the path to ...\xgboost\rabit\include and ...\xgboost\include
I put the xgboost.dll in the directory where the .exe is generated.
From here, it was smooth sailing.
=-=-=-=-=-=
Here's what I've done to create a Visual C++ DLL Project:
After choosing File > New > Project, I select an ATL DLL Project (this is part of the project requirement).
For the XGBoost include to the project, I repeated steps 1-5 above, but placed the xgboost.dll file where the
project DLL would be generated.
Here is the source for the header file for the simple class I have created:
#pragma once
class XGB_Driver
{
public:
XGB_Driver();
~XGB_Driver();
float callXGB(float sample_input);
};
Here is the source for the simple cpp file:
#include <xgboost/c_api.h>
#include "stdafx.h"
#include "XGB_Driver.h"
XGB_Driver::XGB_Driver()
{
}
XGB_Driver::~XGB_Driver()
{
}
float XGB_Driver::callXGB(float simple_input) {
BoosterHandle my_handle;
return(0);
}
Why this doesn't work for the ATL DLL project, but does for the console app really has me banging my head against the keyboard.
Your help would be very much appreciated.
Best,
Dave
With the help of CristiFati, I believe this question has been answered.
For whatever reason, it seems that using XGBoost with C++ in a DLL project requires additional includes above and beyond what is required for using it in a console application.
I am currently building the DLL project with the addition of:
#include <cstdint>

native WebRTC with Visual Studio build error

I've succcessfully build native WebRTC and got webrtc.lib file in result. Then i was trying to setup Visual Studio 2017 simple project to use webrtc and I pointed include and library directory and also in dependencies added webrtc.lib. For some reason just simple code like this:
#define WEBRTC_WIN
#include<iostream>
#include<api/mediastreaminterface.h>
int main(int argc, char** argv)
{
return 0;
}
generates around 100 errors mainly about min and max functions and rtc::rtc namespace which is weird looks like somehow all rtc::x calls it interprets as rtc::rtc:x for example
Error C2039 'scoped_refptr': is not a member of 'rtc::rtc' webrtctest c:\libwebrtc\webrtc\src\api\mediastreaminterface.h 287
I've tried to download already compiled versions with different include files but got same errors. Also there is an error saying
Error C2059 syntax error: 'namespace' webrtctest c:\libwebrtc\webrtc\src\rtc_base\messagequeue.h 33
which is pointing to this line:
namespace rtc {
I've downloaded latest branch-69, and my windows sdk version is 10.0.17134.0
I've managed to make it work. I had to add #define NOMINMAX on top of everything because there were macros inside of windows.h with same name.