When trying to build a C++ project in Visual Studio 2022 I get:
Cannot open include file: 'boost/asio.hpp': No such file or directory
Include line causing error:
#include <boost/asio.hpp>
But I did include the path to this file through Additional Include Directories already.
In my user's desktop directory x64-windows\include folder contains boost folder, which contains the included asio.hpp file. It also contains asio folder.
Edit: Changing <boost/asio.hpp> to "boost/asio.hpp" doesn't help.
This fixed it for me:
.\\vcpkg.exe integrate install
it returned:
Applied user-wide integration for this vcpkg root.
All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
Now the project compiles without any problem.
I downloaded this project's files which is written in visual studio and I am trying to make it compile in Code Blocks. The issue I am having, is with the StdAfx.h/.c files, which if I understand this correctly, are used for Visual studio.
So the error is:
fatal error: afxwin.h: No such file or directory
I get this error inside AtdAfx.h file, because it tried to include it:
#include <afxwin.h> // MFC core and standard components
If I try to delete the AtdAfx.h, my other project's files give me errors, since evey one of them uses the AtdAfx.h.
Side note:
This is the exact error I have Fatal error c1083 "afxwin.h" but he/she uses Visual studio, I use Code::Blocks.
I would like to solve this issue once for all, what is the best best to compile a .cpp file that uses windows libraries (to create a exe file).
For instance I have this cpp starting with:
#include "stdafx.h"
#include <Windows.h>
And I get
stdafx.h: No such file or directory
Windows.h: No such file or directory
I know for instance that stdafx require Visual C++ on Windows, but I want to compile it on Linux, how would you do ?
Thanks a lot
The short answer is you cannot build a Windows executable on Linux. But you can download the free Visual Studio Community Edition to build it on Windows.
stdafx.h is a header file in your project. It is used by Visual Studio's pre-compiled headers feature. If you use a predefined project template, Visual Studio will auto-generate stdafx.h and mark it for pre-compilation. You then include the common C++ headers, e.g. STL, in stdafx.h and include stdafx.h in each of your source code files.
When you are not using Visual Studio stdafx.h is a convenient place to pull in the standard headers for runtime libraries but serves no other purpose.
windows.h is the header file for Windows runtime APIs. The Windows APIs and hence the headers are not available on Linux. If you want to build an executable on Linux to run on Linux then you must replace Windows APIs with the Linux equivalents.
I'm running a simple program with Qt5, QtCreator under windows 7+msvc2010 with SDK7 installed. I have to call specific Windows functions in this program.
If I try to compile it, I always get:
error: C1083: Cannot open include file: 'Windows.h': No such file or directory.
Of course, I set "normally" the dev. kit in QtCreator (Microsoft Visual C++ Compiler 10.0), and I try to run vcvars32.bat before. It still is not working.
Another point: Why when while compiling, do I not see any include (-I...) related to the Windows SDK?
Where is my mistake?
I have windows 7 (64-bit) and I am trying to configure opencv 2.2 for Microsoft visual studio 2010, I followed the instructions given in the book OpenCV 2 Computer Vision Application Programming Cookbook , but it’s not working, I performed the following steps:
Compile opencv 2.2 using cmake, (source code: C:/OpenCV-2.2.0, where to build binaries: C:/OpenCV-2.2.0/build)
Open OpenCV.sln (which is made as a result of compiling by cmake in the folder C:\OpenCV-2.2.0\build), this is opened in visual studio, I build it (result of build: no errors, few warnings).
Add new property sheet to my project, and in VC++ directories, under the “Include Directories “ I give the path of C:\OpenCV-2.2.0\include\opencv and under the “Library Directories” I give the path of my lib files i.e C:\OpenCV-2.2.0\build\lib\Debug.
Within the linker tab under the Input, included the following Additional dependencies:
opencv_core220d.lib
opencv_highgui220d.lib
opencv_features2d220d.lib
opencv_calib3d220d.lib
According to the instructions on the book now everything should be configured correctly, but when I include header files,(after typing (Hash)include (angle bracket)) the intellisense only gives:
#include <cxcore.h>
#include <cv.h>
but instead it should had displayed
#include <opencv2/core/core.hpp>
and when I write
#include <opencv2/core/core.hpp>
it gives me error cannot open source file
“opencv2/core/core.hpp“ ,
if I include
#include <cv.h >
I got 11 errors:
1. IntelliSense: cannot open source file "opencv2/core/core_c.h" c:\opencv- 2.2.0\include\opencv\cv.h 63 1
2. IntelliSense: cannot open source file "opencv2/core/core.hpp" c:\opencv-2.2.0\include\opencv\cv.h 64 1
3. IntelliSense: cannot open source file "opencv2/imgproc/imgproc_c.h" c:\opencv-2.2.0\include\opencv\cv.h 65 1
4. IntelliSense: cannot open source file "opencv2/imgproc/imgproc.hpp" c:\opencv-2.2.0\include\opencv\cv.h 66 1
[The remaining errors are similar to the above errors.]
I have not included anything under the C/C++ -> General -> Additional Include Directories
in the property sheet, is there any need to include anything there ???
Can anybody please tell me, what I did wrong in the configuring process?
Is there any guide available specifically for configuring opencv 2.2 on windows 7 (64-bit) on visual studio 2010?
Maximus solution sounds like a spray and pray attempt.
I cleanly only added [opencvDir]\include to my visual studio includes and it all worked really fine.
Including with your syntax
#include <opencv2/core/core.hpp>
works just fine, thats how i do it. The rest of the steps I did was exactly what you described, except that I have different projects with different parallel opencv installations, so i did not add OpenCV to my global environment variable "PATH" but rather than that I selectively use OpenCV for each project by selection Project Properies (right click project, select properties) => Debugging => "Environment" : Set to PATH=$(SolutionDir)Dependencies\opencv2.2\x86\bin" (in my case), and "merge environment" to "yes"
That is necessary so opencv finds its DLLs in case you link non-static.
Hope that helps :)
You need two include directories. For me it was, C:\OpenCV2.2\include and C:\OpenCV2.2\include\opencv
Try including all directories in C:\opencv-2.2.0\modules\module_name\include
For example in your case it could be
C:\opencv-2.2.0\modules\core\include\
C:\opencv-2.2.0\modules\imgproc\include\
and many more. You should use comand line to get that list of directories in the C:\opencv-2.2.0\modules. And after each add include.
I don't know why does this happens..
In my property page,
in C/C++ -> Addictional Include Directory
I was using "%OPENCV_DIR\build\include"
Replacing by the real path fixed the issue with intellisense:
"C:\opencv\build\include"
I am running opencv 2.4.2 and Visual Studio 2010 SP1.