I have a program that has several header files in a folder. Is there a way I can have the program automatically search through this folder whenever the particular .h is called?

Dani AI

Generated

As hinted, the compiler will only find headers in folders you tell it to look in. On Windows with Visual Studio 2005 (as you said, ), the clean way is to add the plugin header folder to Visual C++'s include paths rather than relying on Windows to "auto-search."

Per-project:
Right-click the project -> Properties. With the appropriate Configuration selected (pick "All Configurations" if you want it applied everywhere), go to Configuration Properties -> C/C++ -> General -> Additional Include Directories and add the plugin folder(s). Use Visual Studio macros or relative paths for portability, for example $(SolutionDir)\plugins\include or ..\plugins\include. If the plugin also ships libraries, also add their folder under Linker -> General -> Additional Library Directories and list the .lib names under Linker -> Input -> Additional Dependencies.

Sharing settings:
Create a property sheet so multiple projects use the same include list. Open Property Manager (View -> Other Windows -> Property Manager), add a new .vsprops sheet, edit it and set Additional Include Directories there, then attach the sheet to other projects. For a global, per-user change you can edit Tools -> Options -> Projects and Solutions -> VC++ Directories (less portable).

Troubleshooting and tips:
Enable the compiler include trace (add /showIncludes in the C/C++ command line) to see where the compiler looks. If Intellisense is out of sync, delete the .ncb file or restart the IDE. Make sure you set the path for the correct configuration/platform and check whether the plugin expects a single master header or extra preprocessor defines. Use #include "file.h" for headers intended to live next to your sources and <file.h> for ones coming from include paths.

Recommended Answers

All 6 Replies

If you have
a.h
b.h
c.h

And you include a.h, what exactly are you hoping to achieve with the other header(s) ?

So, more specifically, i recieved a plug-in from a company that has a lot of .h files that are necessary for the program to run however not all of the .h files in the plug in are needed. I was wondering if there is a way to set a search or second directory that the program looks to whenever a specific .h file is called

Plugin A is compiled, and includes a.h
Plugin B is compiled, and includes a.h and b.h

You just (assuming gcc) have
gcc -c -I/path/to/plugin/headers plugina.c pluginb.c

Where /path/to/plugin/headers/a.h is an absolute path name.

I appologize for my lack of experience, however I am not sure how to set the path. Could you possibly give some pointers on how to accomplish this? Thanks

I have windows Vista with visual studio 2005

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.