简体   繁体   中英

file found from one .cpp file, but give “No such file or directory” from another .cpp file

in CCellBridge.cpp, CCellBridge.h is found
but in main.cpp, CCellBridge.h gives:

main.cpp:15:25: fatal error: CCellBridge.h: No such file or directory
  #include "CCellBridge.h"

i even copy/paste

#include "CCellBridge.h"

from CCellBridge.cpp into main.cpp

in main.cpp, it will see the functions from CCellBridge.h

i have cleaned/compiled, closed, clean/compiled, but the error still shows. how can the IDE see the class, but the compiler can not? both files are in same project. i have closed file and opened file in project just to make sure it was the correct file.

this is in main, it sees it. no yellow or red lines under code.

CCellBridge cellBridge = new CCellBridge();
cellBridge.GetFire();

type

cellBridge.

and list of functions show up

yet

#include "CCellBridge.h"

in main.cpp has yellow line under it

guess this needs clarifying:
file CCellBridge.cpp

 //
 #include "CCellBridge.h"

 CCellBridge::CCellBridge()
 {

 }

works

file main.cpp

 #include <cstdlib>
 #include "CCellBridge.h"

 using namespace std;

 int main(int argc, char** argv) 
 {
     CCellBridge cellBridge = new CCellBridge();
     return 0;
 }

does not work

file main.cpp

 #include <cstdlib>
 #include "CCellBridge.h"

 using namespace std;

 int main(int argc, char** argv) 
 {
     CCellBridge cellBridge = new CCellBridge();
     cellBridge.  [note: this give list of function in class CCellBridge]
     return 0;
 }

Did you add the include directories path properly in the Project Settings in your IDE(assuming its Visual Studio). Open C/C++ General tab in VS IDE and check against the first entry "Additional Include Directories". The directory containing "CCellBridge.h" should be present in this list. Let me know if this helps!!

i verified that it was NOT in same folder. had to remove files from project, copy files to project folder, add files to project.

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