It is all fine when I was writing the code, that is, when I included the header file "opencv2/opencv.hpp",and VS2019 can indeed "see" it,in other words, I can use the class that is in the opencv.hpp, but only when I complied the project,c1083 occurred
before i added the function DrawLine(),i compiled for times,with no err.and then i added the function DrawLine(..),error occurred
this is the total source code
a.ha.cpp
//a.h
#include<opencv2\opencv.hpp>
using namespace cv;
class Canvas{
Mat mat_canvas;
void Init(){
mat_canvas.create(1024,1024,CV_32FC3);
}
void DrawLine(float ax,float ay,float bx,float by);
}
//a.cpp
#include"a.h"
void Canvas::DrawLine(float ax,float ay,float bx,float by){
cv::line(this->mat_canvas,Point2f(ax,ax),Point2f(bx,by),Scalar(1,1,1));
}
error msg was:
fatal error C1083 Cannot open header file: 'opencv.hpp': no such file or dir
i know i can create a new solution and move my old solution to it,but it takes time,and i can't actually know whether this issue will happen again in my new solution
Any answer will be helpful
Actually there are most of the time possibility of missing "Additional include directory path" or wrongly setup.
Where to find in Visual Studio:
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set
C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > General property page.
Modify the Additional Include Directories property.
Visual Studio 2019 C++ Project configuration
Example project setup is described in below link:
Example setup
Related
i m trying to use sfml in my project using visual studio 2019. Following sfml documentation to perform setup for visual studio i have performed all the action required
i have included include folder in c/c++/additional include directory and also provided path for lib folder in linker setting and also provided additional dependencies in linker/input
but
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
std::cout << "i cant tolerate" << std::endl;
return 0;
}
this code shows above mentioned error ,
cannot open include file 'Graphics.hpp' no such file or directory
it seems like include path is not working
how can i solve this issue
i tried many times but got same result
if anyone facing the same problem please check the platform in the project/properties win32 worked for my particular problem
I have found two similar questions this and this .
But they both use opencv, and opencv indeed provide the corresponding lib. I don't use opencv, and my project is very simple, just hello world.I have changed project default configuration like this
except for these configurations, others all take defaults
I just want to test my project configuration,that works find for win32 debug and release. But not work for x64 debug and release, they all tell me LINK : fatal error LNK1104: cannot open file 'opencv_world341d.lib'
I indeed know my project does not use any opencv lib, but why they tell me I need to use opencv_world341d.lib
my code
#include<iostream>
using namespace std;
int main()
{
cout << "hello world" << endl;
}
Thanks for everyone who comments on the question. I have solved the problem, although this problem not relevant to OpenCV to much, but I think the solution to the problem may be helpful to others. When I build project, visual studio 2019 tell me cannot link opencv_world341d.lib, so I go to Project->Properties->Linker->Input->Additional Dependencies , and I found opencv_world341d.lib. So I need to remove it, but it's readonly. From this we know visual studio using settings file (Microsoft.cpp..users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory. Then I reedit Microsoft.cpp.<Platform>.users.props, delete opencv_world341d.lib, reboot visual studio, problem solved.
OS -Windows 10 x64
Library mqtt
Microsoft Visual Studio Community 2017 Version 15.9.15
Programming Language - C++17
Installed paho-mqtt paho-mqttpp3 paho-mqttpp3[ssl] using vcpkg
I am creating a c++ program using mqtt.
But whenever I am using below given header
#include <mqtt/async_client.h>
It is giving following error
d:\vcpkg\installed\x64-windows\include\mqtt\async_client.h(27): fatal error C1083: Cannot open include file: 'MQTTAsync.h': No such file or directory
But MQTTAsync.h file is available on the given location
D:\vcpkg\installed\x64-windows\include\paho-mqtt
I had followed below link by creating new console project
https://github.com/Microsoft/vcpkg/issues/1848
Still issue is not getting resolved
Verify the correct name in your vcpkg-directory.
In my case that would be C:\Users\USERNAME\vcpkg\installed\x64-windows\include\paho-mqtt
Here you will see that the header file you are looking for is actually called MQTTAsync.h
To add it in your project you will have to change your inlcude to #include <paho-mqtt/MQTTAsync.h>
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>
I have read a ton of this same question, but I appear to be doing everything correctly as all suggestions advise, but am still getting this error.
I have simple .cpp and .h files in C++ using Visual Studio 2015. My program runs perfect from the gui. I need to run it in the visual studio developer command window to get the results there, this is a verified console application. I have copied the files to their own directory using:
C:\RunDirectory>copy C:\SaveDirectory\
The system verifies that it copies all 15 files.
When I run this command:
C:\RunDirectory>cl Aprogram.cpp
Then I get the error.
I have a main that is returning an int, and this is a console application with the correct linker settings: Console (/SUBSYSTEM:CONSOLE)
Any ideas? I'm pretty stumped.
This is my driver file:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include "JollyBanker.h"
using namespace std;
int main()
{
JollyBanker theBanker;
theBanker.BuildQueue("BankTransIn.txt");
theBanker.ProcessQueue();
theBanker.DisplayResults();
return 0;
}
File Aprogram.cpp is a source code file, which is compiled and linked
into an executable by Visual Studio IDE. Assuming that default project
settings are used, this executable is located in "Debug" or "Release"
subdirectory of the directory that contains your solution and it is named
ProjectName.exe (where "ProjectName" is the name of the project
within the solution that contains Aprogram.cpp)
Also, you mentioned that you want to make sure it works outside VS. Note
that if you have used the default settings, you will have problems when you
run this executable on another machine. To solve this, I suggest that you
change the runtime library that you are linking to. To do this, right click on
the project in Solution Explorer and select "Properties". Go to "C/C++" -> "Code Generation"
and change the value of "Runtime Library" to "Multi-threaded Debug (/MTd)" for "Debug" configuration, or to "Multi-threaded (/MT)" for "Release" configuration.