简体   繁体   中英

Cannot open include file error but able to locate file

I'm getting the following error :

"fatal error C1083: Cannot open include file" 

for one of my header files being #included in stdafx.h . I have set the include and library paths in the project dependencies, Tried to include them in additional include section. On top of that when I right click the

    #include <BCGCBProInc.h>

it is able to open the file and show it to me. So it can find and open the file but instead gives me the error. I am using VS2012 on Windows 7 and the header is in a different location then the project.

What am I doing wrong / not doing right?

1.

#include <BCGCBProInc.h>

is not the same as

2.

#include "BCGCBProInc.h"

Different search pathes apply to both variants of including a file.

The pathes looked up when using variant 1. are those defined as default search pathes like

  • /usr/include for IXish systems
  • $(VCInstallDir)include also called VC++ Directories for VC

The pathes used when using 2. are those added via the option -I ( /I for VC).

In Visual Studio, right-click your project and choose Properties. Select the VC++ Directories option in the left pane, and then look at the Include Directories and Library Directories in the right pane. Make sure they are using relative paths and not absolute paths. If they must be absolute paths, then every machine you run this project on will have to have the exact same path. Absolute paths look like this:

D:/Development/MyProject/includes

Relative paths can be done using $(ProjectDir) to make it relative to the project, or $(SolutionDir) to make it relative to the solution (if different from project), and would look something like this:

$(ProjectDir)../includes

or

$(SolutionDir)includes

What I had to do to get it to compile was change

    #include "BCGCBProInc.h"

to this

    #include "C:\Program Files (x86)\BCGSoft\BCGControlBar Professional Evaluation\BCGCBPro\BCGCBProInc.h"

I'm not sure why because I included the path in the VC++ Directories. When I browse for the path it changes (x86) to %29x86%29 which is what I thoght was screwing it up but that is not the case because I manually changed it back to (x86).

My plan is when I eventually get what i need to get done, I will bring the libs and includes into the project locally and make the paths relative

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM