include a file from seperate folder in c++ - c++

well, I am trying to include a header file in my project, while the header actually belongs to the other project in the same workspace.
I don't want to do something like
../../folder_name/header_file_name.
If it helps I am using VisualC++ 6.0.
Thanks!

1. Right-click on the project, and select Properties.
2. Select Configuration Properties->C/C++->General.
3. Set the path under Additional Include Directories.

For Visual C++ 6.0, go to Tools / Options / Directories / Show directories for: Include files, and then add the full path to the folder where your other header file resides.

Add the other folder as an Include Directory to your project, so that it's in the search path.
You may also need to add a Library Directory if this header has a corresponding object file.

You can tell to compiler a path to search header files.Look at your project configuration.
Look at to the first pict here: http://www.steptools.com/support/stdev_docs/help/settings_vc6.html

Related

Is it possible to override an include file from a project dependency

I have a project that uses includes from other projects. This works fine, however one of the includes references a file that I would like to somehow overwrite.
Is this possible? If I include a file with the same name in my project will that somehow overwrite it on compilation? Unfortunately I don't have write access to that file, so I need to find a work around and substitute my own file. This is with Visual Studio 2017.
Put your header file directory to beggining of your include search path "Additional Include Directories". So compiler will find your header file first.

Eclipse Include Paths outside Project Directory

I am having an issue including files outside my project directory. I have a project in eclipse with some header files outside of the project that need to be linked to my project. I have added the path to C/C++ General for the header files and included them in my code. It seems like only one of the files can be seen and the other file I am getting an unresolved inclusion error. Does anyone know how to fix this?
The following is thanks to comments from #user7860670 -- you can see more commentary in eclipse: including a path outside of the project
Short form:
Use system variables.
For include directories relative to your workspace, use something of the form "${workspace_loc}/../my_includes".
For include directories relative to your project, use something of the form "${project_loc}/../my_includes".
Note that in some IDEs, the system variables may be named differently.
See eclipse: including a path outside of the project for more details.

Include c++ files outside project directory in Eclipse

I have a problem regarding including files that are outside project directory (c). So I have a project in a workspace. There is a folder somewhere on my hard drive, containing a pair of .h and .c files. I would like to use them in several projects, that's why I wanted to place it outside the project.
I tried including this folder, .h file actually in many ways, but the compiler doesn't seem to see the content of it. I can successfully include the file, but the functions inside are not visible.
In the properties of the project -> C/C++ General -> Paths and symbols I have added the folder. What else should I do?
Add the relative path of all those *.c and *.h file.
#include "path_to_header/lib1.h"
#include "path_to_file/file1.c"
I was wondering about the same recently, here is what worked for me:
You have to mark the files as source code. Open project properties dialog and go to source location tab
then you can use Link Folder to select absolute path or you can use the variables to keep it relative to project file or workspace.
For other configurations Add folder was enough since they were already linked.
You also need to add include paths to c or c++ here
There probably already are some default paths so just add the new ones.
It can also be relative using variables.
I had more sub folders so I added them individually and did not use and relative path in #include at all.

visual studio 2012 adding new header file

In Visual Studio 2012 (C++ environment), for a Win32 console application, I need to include a new header file to my project. I tried copying the files in the project's location but that is of no help. The file is iGraphics.h and it is shown in the header files list but does not compile. What should be the correct approach?
You should add the path to that header to the additional include directories under C/C++ in your project settings. Afterwards, just #include "iGraphics.h" where you need it.
Don't just move header files around, and don't add existing headers to your project for no good reason. This way, you can easily change versions by just specifying a different folder.
The easiest way to do this is:
Right click on the header file (to be included) in the Solution explorer.
General->"Excluded from the build"
Select "No" from the drop down list
Click "OK".
In VS2012, just using '"' instead of '<>' around the header file in include also works.
Put the file in the right place in the file system (like you did). Then right-click your project in the solution explorer and use Add > Existing Item to add it to your project.
If you don't want to move your file (which you probably should not), see Luchian's answer on how to add the include directory to the include folders.

How to include a included header file from one project to another? VS2008

I have a project called Configurationhandler, and I have included a header file xerces\DomParser.hpp in Configurationhandler.h
And ConfigurationHandler.h is included in HouseKeeper.h. But when I try to build, the ConfigurationHandler builds without errors, but HouseKeeper project gives an error saying it can't find the file.
EDIT: Both projects are within the same solution.
Assuming HouseKeeper is a different project, you'll need to add the path to the directory containing ConfigurationHandler.h into your HouseKeeper project settings..
I don't have VS2008 handy, but on VS2005, it would be:
Right-click on the project in the Solution Explorer
Select properties
Under Configuration Properties\C/C++\General you should see 'Additional Include Directories' - add the path in here