Error while using Boost with Visual Studio 2008 - c++

I am using Boost with Visual Studio 2008 and I have put the path to boost directory in configuration for the project in C++/General/"Additional Include Directories" and in Linker/General/"Additional Library Directories". (as it says here: http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html#build-from-the-visual-studio-ide)
When I build my program, I get an error:
fatal error C1083: Cannot open include file: 'boost/python.hpp': No such file or directory
I have checked if the file exists, and it is on the path.
I would be grateful if anyone can solve this problem.
The boost include path is C:\Program Files\boost\boost_1_36_0\boost.
Linker path is C:\Program Files\boost\boost_1_36_0\lib.
The file python.hpp exists on the include path.

Where is the file located, and which include path did you specify? (And how is the file #include'd)
There's a mismatch between some of these But it's impossible to say what's wrong when you haven't shown what you actually did.
Edit:
Given the paths you mentioned in comments, the problem is that they don't add up.
If the include path is C:\Program Files\boost\boost_1_36_0\boost, and you then try to include 'boost/python.hpp", the compiler searches for this file in the include path, which means it looks for C:\Program Files\boost\boost_1_36_0\boost\boost\python.hpp, which doesn't exist.
The include path should be set to C:\Program Files\boost\boost_1_36_0 instead.

How do you include it? You should write something like this:
#include <boost/python.hpp>
Note that Additional Include Directories settings are differs in Release and Debug configurations. You should make them the same.
If boost placed to C:\Program Files\boost\boost_1_36_0\ you should set path to C:\Program Files\boost\boost_1_36_0\ without boost in the end.

Related

How to reference header files in visual studio 2017 project

I have downloaded and tried to build The oxygine engine project with VS 2017 Community. The stringutils.cpp file from it gives me the following when I try to compile:
C1083: Cannot open include file: 'SDL_stdinc.h': No such file or directory
hovering the #include statement it says cannot open source file 'SDL_stdinc.h'
I checked
Properties->C/C++->General->Additional Include Directories
and it references the path the header files are in. I have even added another path representing the absolute path. I tried a different folder, a different download of the header files, all to no avail.
What do I need to do to get this right?
Is there any reason for a header to not work? (version mismatch or something)
Is a header not working if the corresponding dll or lib is missing?
If so, how do I know it is found by VS?
The problem was the path for oxygine in the oxigine project properties was setup like this ..\..\..\..\SDL\include\ but had to be setup like that ..\..\SDL\include\

Cannot open file 'SDL2.lib' and Cannot open file 'uctrtd.lib'

I'm trying to follow this tutorial to get SDL working. I've followed the steps he outlined:
In my properties under VC++ Directories I have:
Include Directories
C:\SDL2-2.0.4\include;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;
$(IncludePath)
Library Directories
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;
C:\SDL2-2.0.4\lib;
$(LibraryPath)
Under Linker > General I have:
Additional Library Directories
%(AdditionalLibraryDirectories)
I also have SDL2.dll placed in E:\Dev\cpp\SDL Setup\MyProject\Debug
When I have it like this I get the error Cannot open file 'SDL2.lib' but if I set the directory to the SDL lib (I.E. C:\SDL2-2.0.4\lib\x64) it no longer displays the error but then shows the error Cannot open file 'uctrtd.lib'.
I'm not sure if that error is a step in the right direction. Any help would be greatly appreciated.
From your post, it is evident that LIB files are present at:
C:\SDL2-2.0.4\lib\x64;
and not at:
C:\SDL2-2.0.4\lib;
So, you must use the x64 path to get the lib. It is also visible that .LIB for 64-bit are present in x64 folder, and there must be something for 32-bit linking (in C:\SDL2-2.0.4\lib itself) - for you 32-bit build.
Please fix it gradually, calmly and in step-by-step manner.
The error you are later getting for uctrtd.lib is probably because you messed up standard LIB paths. Bring the original LIB paths back, and append this library's LIB path.

Dlib Error: error C1083: Cannot open include file:'type_safe_union/type_safe_union_kernel.h'

I'd like to use the image processing package of Dlib (C++ library) in Visual Studio 2013.
I created an empty project and added "dlib-18.16\dlib\all\source.cpp" to my Source Files in the Solution Explorer. Then, I added the path to dlib-18.16 to my Include Directories in VC++ Directories and I also added the path to dlib-18.16\dlib to my Additional Include Directories in C/C++ General of Visual Studio.
I can run the file matrix_ex.cpp which is one of the examples of Dlib, but I can't run the file face_detection_ex.cpp because of the error " Cannot open include file:'type_safe_union/type_safe_union_kernel.h' " which is actually caused by the line #include <dlib/image_processing/frontal_face_detector.h>
How can I resolve this issue? Why the program finds some header files but it can't find the others while they are all located in the same folder?
You need to add the dlib folder itself to the Include Directories in VC++ Directories, you instead added the folder above it.
By extension that would mean your include directive needs to be #include <image_processing/frontal_face_detector.h>.
Let me list a hypothetical example to explain better. You downloaded dlib-18.16.tar.bz2 and extracted it to c:\projects. This creates a folder named c:\projects\dlib-18.16. Within VC++ Directories you added c:\projects\dlib-18.16 to the Include Directories.
However this isn't correct, you should remove that directory and instead add c:\projects\dlib-18.16\dlib as that is the include directory for the project.
That will cause #include <type_safe_union/type_safe_union_kernel.h> to load C:\projects\dlib-18.16\dlib\type_safe_union\type_safe_union_kernel.h as well as similar internal links between files.

How to add a header file in Visual Studio 2013, C++

I use Visual Studio 2013 to build a program. I have got some problems...
a) an error:
c:\users\wojciech\desktop\cryingdamson 0.3.6 (8.60) v8.2 source\otpch.h(28): fatal error C1083: Cannot open include file: 'libxml/xmlmemory.h': No such file or directory
My code:
#include <libxml/xmlmemory.h>
I have included that file in Visual Studio 2013 to header files and I have even it at libxml folder. I can not still build solution (compile) because of that error.
Please help me, I am new to Visual Studio. I have tried to add xmlmemory.h file to project properties, but it seems that it doesn't see the file.
Okay, in folder "c:\users\wojciech\my documents/visual studio 2013/projects/consoleapplication3" there is a file named MainProject.sln, which type is microsoft visual solution. In the same folder I have added libxml folder and in the folder I have put xmlmemory.h. The problem is I still can not compile the program.
I use windows 7.
You Need to add the parent Folder of libxml to the include path. Say if the Folder structure Looks like
some_project
include
libxml
xmlmemory.h
...
you Need to add the include Directory to the include path
Where is your xmlmemory.h? Of #include <.../libxml/xmlmemory.h> try a complete path in the ... part.
The path libxml/xmlmemory.h is in fact ./libxml/xmlmemory.h where ./ means the location of your workspace.
===============Next is added according to your comment==========================
Just using #include "..\libxml\xmlmemory.h" would compile. So your workspace path is therefore c:\users\wojciech\my documents/visual studio 2013/projects/consoleapplication3. Under your workspace there should be a folder MainProject where your existed source files are located. So .\ means the path c:\users\wojciech\my documents\visual studio 2013\projects\consoleapplication3\MainProject.
Note that you should use \ other than / to represent your file hierarchy in your project and that you should use "xxx.h" other than <xxx.h>.
You can also use this method: open VIEW->Property Manager, right click on MainProject and open Properties, in C/C++ -> General -> Additional Include Directories, add your folder libxml to it. Then all files under your libxml folder would become a part of your solution. You can just use #include "xmlmemory.h>" to make it compile.
Either way is supposed to compile.

visual studio 2010 include directory paths

I have a visual studio solution myvs.sln with the following path: c:\dir1\dir2\dir3\myvs\myvs\myvs.sln. I have boost version xxx installed in c:\dir1\dir2\dir3\boostxxx\.
I have in the project->properties->c/c++->general: ../..;../../boostxxx. Inside boost libraries the include files have the following syntax: #include <boost/smart_ptr/shared_ptr>.
My code file myfile.h resides in c:\dir1\dir2\dir3\yy1\myfile.h. In myfile.h I include boost libraries as: #include <boost/shared_ptr.hpp>. I am getting a error which says: c:\dir1\dir2\dir3\yyy1/myfile.h fatal error C1083 cannot open include file boost/shared_ptr.hpp.
The question is what should I do to correct this?
I also notice that the error output the compiler throws has "\" upto dir3 and then changes to "/".
Most probably I do not understand how the relative path is working. Also note that I want to refer to only relative path not absolute paths. Can someone please help? I am in windows platform using c++ visual studio 2010.
Relative paths in the search paths refer to the directory of the file with the #include directive the current directory of the compiler, some simple testing now shows.
"..\.." is going up two levels from your header file the current directory of the compiler instead of from your project directory.
To fix this, explicitly start your include paths in your Visual Studio project directory, as follows (literally):
$(ProjectDir)..\..;$(ProjectDir)..\..\BoostXXX
Regarding forward versus backward slash, use forward slash in your C++ code's #include directives, because that's most portable.
Use either forward or backward slash (but I prefer backwards slash so as to have a single convention) where you're referring to the Windows file system, such as in the setup of include paths.