开发者

how to call h files in c++ project

first i created a folder name 'C:MyProject' and then another 2 folders inside the 'MyProject' have created called 'src' and 'include'.After that i opened a new project in c++ and saved it in the 'MyProject' as myproject.dev. t开发者_JAVA百科hen i added 2 folders to my project for that i used same name which i created in my project folder('src','include'). then two headear files i added to the project name a.hpp and b.hpp (inside include folder) and also main file added to the src folder. but when i compiler it shows a error that 'a.hpp:no such file or directory in function main()'. however i wrote a code to read header files from main file ( #include "a.hpp" ) and in my a.hpp, i wrote same code to call b.hpp file. i tried several ways but it shows same error message. so please help me to create a project with header files. thanks


When the prepocessor reads #include "a.hpp" it looks for a.hpp in the current folder. In your case, it means src. But your header files are not there ! They are in C:/MyProjects/include.

You need to tell the compiler where to look for include files. Usually it's something called "include directories" in the project options.


#include "../include/a.hpp" 

or add that folder to project include path

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜