I am trying to compile the Scintilla control with MSVC++ 2010 Express Edition, and it's quite painful getting it to work right because I need a bunch of files. When compiling SString.h, I noticed this:
#include <crtdll/stddef.h>
I am no C++ programmer, but I do understand what
#include <xxx.h>
means, but what does the the that include mean? I get the following error with it:
Error 1 error C1083: Cannot open include file: 'crtdll/stddef.h': No such file or directory f\scintilla\lexers\sstring.h 44
Any help on how I could fix it would be appreciated.
If I am not mistaken, that is just a relative path. In other words, Visual Studio will look for stddef.h in the crtdll subdirectory of, probably, the root directory of the project.
By using the preceding function, you are summoning, and subsequently inserting a header file into your current source code.
In the case of #include <crtdll/stddef.h> you will be inserting the stddef.h header file from the crtdll directory (which should be a child folder defined in your compiler as the holding pen for header files) during the compilation and linking of your program.
By inserting the stddef.h header file into your source you are giving your program the capability to wield NULL pointer constants, which are exceedingly useful in some of the more advanced programs you may or may not have come across.
Good luck with your program!
I am no C++ programmer, but I do understand what
are you sure?
include with <> searches the include paths for the specified file and copies the content the content of that file in your .cpp.
So you are just missing the crtdll/stddef.h file, however stddef.h actually belongs to the C standardlibrary so you might replace it with #include in C or #include in C++
The easiest way would be to check your include directories. crtdll is the C standard library provided by msvc, so maybe you have to add the parent folder of your standard library include directory
This means that stddef.h needs to be included from the crtdll folder.
You need to check your include directories for Visual C++ projects to see that which are the default directories from where Visual Studio looks up for header files.
To fix this error, see that at which path have you installed the Scintilla control. The crtdll folder will be there most probably. And then, add this folder to your visual studio include directories.
You can set it in the following project properties dialog:
Here http://i56.tinypic.com/2zo9guh.jpg
Related
I need to include "\boost\iostreams\device\mapped_file.hpp" in my project. I tried:
#include <\boost\iostreams\device\mapped_file.hpp>,
but it couldn't work. Therefore, I used:
#include "C:\path\boost\iostreams\device\mapped_file.hpp".
As a result, the system could find "mapped_file.hpp" file. However, when I build the project, the system complains:
C:\path\boost\iostreams\device\mapped_file.hpp(14): fatal error C1083:
Cannot open include file: 'boost/config.hpp': No such file or directory
This tells me the way I fixed the first error is incorrect.
I have another project downloaded from a repository that uses boost library. This project is already built successfully in my PC. Everything for the boost library in my PC comes from this project, and the header file I need to use is located in "C:\path\boost\iostreams\device\mapped_file.hpp". In this case, how should I add a path or include "\boost\iostreams\device\mapped_file.hpp" to fix my current problem?
Thanks in advance!
I need to include "\boost\iostreams\device\mapped_file.hpp" in my project.
Actually, no, you don't. You might need to include "boost\iostreams\device\mapped_file.hpp" (no leading slash) in your project, but that leading slash will make it impossible for the compiler to find the header file (unless you installed boost to your root directory – rather rare).
In addition, make sure the compiler knows to look in C:\path\ for included headers. As discussed in the comments, this can be done in Visual Studio 2012 via Project properties → C/C++ → General → Additional Include Directories.
I was trying to re-use an available source code for my own project, it can be found here:
https://github.com/TadasBaltrusaitis/OpenFace
I tried compiling project FeatureExtraction of the original code, everything was fine. Then I created a new empty project and added the following #include:
#include "LandmarkCoreIncludes.h"
#include <Face_utils.h>
#include <FaceAnalyser.h>
#include <GazeEstimation.h>
These are exactly the same as in project FeatureExtraction in the provided source code. I've already changed the additional include directories in C/C++ general tab into:
$(SolutionDir)\lib\local\FaceAnalyser\include
$(SolutionDir)\lib\local\LandmarkDetector\include
However, it still gave me "cannot open source file error".
Update: If I put the absolute path of the header file directly to the code it is OK, however if I put the absolute path to the Additional Include Directories, the error remained.
Use #include "header.h" instead of the one with diamonds (< and >) which looks in another directory.
After that, check if the header files really are in these directories. If they are, you should check the $(SolutionDir) ( I don't use a '\' after the $(SolutionDir) but it may work out as well).
Try to locate and delete the .suo file and restart VS
Looks like I had same "bug" as mentioned in this post here:
Visual Studio does not honor include directories
After having changed the Additional Include Directories for all platforms instead, the code was compiled without any errors.
After adding the include directory of the library which I am using. Visual Studio 2010 is able to find the header files I #included into my source code (IntelliSense does not show any errors). However when building the solution, it tells me that it wasn't able to find the header file. The same property used in my previous project does not post this issue.
The only solution I have now is to use the direct address for all the header files from that library, but I find it very irritating to do so, as the header files of the library cross reference each other and it does not make sense to edit all of them.
Does anyone have any idea what causing this problem?
It might because you have source + headers in 2 directories that refer to each other's header files. I.e. the files are
1/a.c
1/a.h
2/b.c
2/b.h
and the contents of a.c and b.c have the same includes
#include "a.h"
#include "b.h"
Your project can find a.h when compiling a.c, and it can find b.h when compiling b.c (since the same directory is assumed in the search path when you use double-quotes in #include "xxx"). But a.c can't find b.h and b.c can't find a.h by default. Your project might be in directory 1 and you may have set up the include directory to look at 2. That works fine until 2/b.c needs to include "a.h". You need to set up the include directory path to include 1 as well as 2, even though 1 is your original project directory and it seems silly to do that.
This is a reason why IntelliSense can open the files (since it is omniscient), but the compiler can't (since it just looks at one file at a time).
IntelliSense uses a slightly different algorithm when searching for include files compared to the compiler & linker. In particular, it can also (sometimes) find header files even though the include directories are not properly specified.
I'll assume you specified the include directories correctly.
An idea: There's a bug in Visual Studio 2010 that if you specify a rooted path (ex. \myproject\includes), then when building the solution, VS uses the drive where it is installed (usually C:) rather than the drive where the solution is located. If this is the case, you'll have to either specify the drive (ex. D:\myproject\includes) or use a relative path (ex. ..\..\myproject\includes).
It seem like the actual problem is cause by me not adding the include directory in the project which was referring to the project which was implementing the library.
This explain why I could build the referred project by itself and only having the problem when I compiled the solution as a whole.
I find this rather dumb to require us to re-declare the include directories in referring project when we have already done so in the referred project
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.
I am having a problem of getting compile errors (red underlines) like:
Error: cannot open source file "stdafx.h"
Here an edited screenshot of the environment:
On the LEFT is my Visual Studio Solution Directory list with the "Show All Files" off.
I am working on a school project, and each Folder are the source files of different parts of the project with different people who are in-charge of them.
For example, Student A and B are incharge of AST and PARSER folders (we will call them sub-projects).
We have an API for each sub-project so other sub-projects know what to call.
At the TOP-CENTER, we have my Source File for a class QueryProcessor. (just the first few lines)
Below it, is the Output for the Build Success.
The red lines are all over all the classes, mainly cause the #include "stdafx.h" cannot be opened by the environment.
On the RIGHT, that is the stdafx.h where we include all the different sub-projects so we save the trouble of each project having a different stdafx.h
However, I am able to build the project. I am pretty sure I am doing this directory/linking wrongly.
This should work
Right click on the solution file
Click Open in Windows Explorer
Find file stdfx.h in explorer and copy the path of the folder
In visual studio solution explorer, Right click on the project file
Click properties-> C/C++ -> General
In the Additional Include Directories paste the path
Combining folders and virtual folders in VC is from my point of view messy because the virtual folders indicate that all files are in one directory and the folders created on the harddrive obviously indicate that all files are in different directories. You can combine it if you know what's going on but in your case I would not recommend it.
I assume you missunderstand the purpose of stdafx.h The purpose of this header file is NOT to put all header filles into it and then just include it to all other files. Here is a SO question about this Purpose of stdafx.h
After cleaning up your stdafx.h file include as many header files into your .cpp files and only put these includes in your header files if they are required in the header file
Turn on show all files, now you will work with actual folders and you can be sure that if you adress a folder like "PKB" that this folder really exists since you can see it in the left solution explorer.
If you use using namespace std; for example make sure you also include the required header files. You might think "hey I already included e.g. iostream in another header file which I now include in this header file so I don't need it" That will really destroy you when you work with bigger projects.
Oh and regarding the stdafx.h include problem as soon as you switch to show all files I assume you will realise that stdafx is in a different file than the file where you use the include. Maybe something like #include "..\stdafx.h" is required (depending on your structure).
I think it's obivious but if you include a header file the include is allway relative to the file which is including the other header file.
stdafx.h is commonly used for creating a precompiled-header, which essentially is a compile-time optimisation such that the compiler will not continually compile these headers for every compilation unit.
If any of these headers changes, you will need to do a full system rebuild.
In reality it is preferable only to use it to include standard headers plus third-party headers (like boost libraries and similar) that you are not ever going to change.
You may decide that some of your own libraries are "set in stone" and can also be included.
Every project, i.e. every part of the project that is built into a separate unit (DLL or .exe) should have its own precompiled header and its own version of stdafx.h
Projects should only ever include their own .stdafx and not those of other projects, therefore this header file can also be used to define your dllexport macro.
When arranging your project headers you should be aware of:
1. Which headers are included externally
2. Which headers are only included internally, and are not even included indirectly externally.
The latter sort should include your stdafx.h file and should ideally not be in the same directory as those headers included from outside your project.