cannot open the header file in C++ - c++

I'm doing my assignment that need to using the #include function
but I found that after I define the header file, I cannot open the header file in the main.cpp
and I also didn't find any xxx.h file in the project file
here is the situation
The reason of search.h can open is I found that in external dependencies file, there is a search.h, but the search.h I want to open is not the search.h in external dependencies file

You don't have header files in your project. Create the header files xxx.h in the project directory. So the compiler will be able to locate them.
If the person who gave you the project has provided you the header files along with the project requirements then, just copy and paste the xxx.h files into the project directory. This would solve your problem.
To learn more about the header file. Click on the below tutorial link
Header Files
How to add header files in Visual Studio 2010 - Youtube

It looks like you don't have any header files included in your project. Visual Studio is attempting to find the header files in the header directory of your project but it cannot find any. Save your header files into separate files and add them to your header directory in the project. Then you should not have any problem.

Related

How to link a folder with some .cpp and .h files in a another directory as a Include path to Unreal Engine Project?

I have a UE4 project , And there is about 10 .cpp and .h files in another directory. I just want to add that directory as an Include path.
We can have script files in Source folder ,but let's say I have a folder with 10 .cpp and header files in D:\MyScripts and my unreal project is in D:\MyProj , I want to unreal to search for source files within that D:\Myscripts folder. when I compile the project, There should be a way to specify include paths.
Is this possible ? if possible how can i do ?
I searched internet nearly for two days, but I couldn't find anything helpful.
Hop someone can help me on this :)
Yes, it is possible. You can create make file and add all the .cpp file and .o file.Reference link here.

Including c++ header files in Xcode without adding the compile source

I'm working to create my own c++ library. I've noticed that I have to add my source file to Compile Sources under Build Phases in Xcode if I include the header file. Obviously, I don't have to go find every Boost or Curl file that I use when including one of those header files.
Currently, my "library" consists of a few header file and source files in the same folder. I have added the path to find the header files to header search paths.
What's the difference between what I'm writing and the standard libraries that only need header file references?

Eclipse CDT: How to make separate header folder?

I was trying to separate my header files (.h) from my (.cpp) implementation by storing them in two different source folders. However, Eclipse then tells the compiler to look for the .h file in the same folder as the .cpp file. This causes the compiler to stop as it can't find the specified file. Is there any way to create such folders in Eclipse and get around this issue?
In visual studio there is separate folder for header files so can we make a separate folder for header files in Eclipse CDT too?

Visual Studio 2012 Error: Cannot open source file

I have source code (header and source files)of a library. I need to include the source code in my existing project. For that purpose i have copied the entire library source code directory into visual studio project folder then i included that directory to VS by using include to project option. Fine.
There is a header file say "x.h" in the library source code directory which defines some macros, and there are some other header files say "y.h" and "z.h" which are using those macros defined in "x.h". But visual studio is not recognising those macros at all when i included those ("y.h" and "z.h") header files in my main class. Visual Studio generates the error "Cannot open this source file".
Actually "y.h" and "z.h" can not find macros defined in "x.h". How to solve this error?
Is there some kind of setting need in the project properties?
My second question is that how to include some programming files in my project correctly so that i can use that library functionality correctly? I have also Include the header directories in configuration properties > VC++ Diectories > Include Directories.
Third question is that is there a way in which i don't have to include the source code to my project? remember i don't have .lib file or .dll file of that library and i cannot compile that library also.
Have you add
#include <x.h>
or
#include "x.h"
Are library files in a sub-folder? if Yes try
#include ".\subfoldername\x.h"

Header files not found

I'm adding unit tests (SenTest) to my existing XCode 4.2 project. XCode is complaining that it can't find the required Box2D header files. For instance,
Box2D/Dynamics/b2Fixture.h file not found
The Box2D source files are added to my project under the "libs" group. The header files are found without a problem when building the non-test target. Obviously, I can't add the header files to the test target, but I've added all of Box2D's .cpp files to that target. That just resulted in more of the "Lexical or Preprocessor Issue"s, as above.
How do I tell XCode where to find these header files?
I don't believe you need to specify the folder when referencing a .h file. If only the .h file is added to the project in any group or subgroup XCode is able to find the path when you reference the .h file by the name only.