User forums > Using Code::Blocks
Add existing file to a project
erotavlas:
--- Quote from: xunxun1982 on November 17, 2010, 04:04:46 pm ---right-click project name -- Add files -- select file.h and click OK
--- End quote ---
I'm sorry If my description is not good, but my problem is the following. I have a project with four file inside the my project folder:
main.cpp
file1.h
file1.cc
data/file2.h
file3.h
Inside of the file1.h there are the lines #include "data/file2.h", #include "file3.h". The compiler tells me: no such file data/file2.h and no such file file3.h.
I can't understand why, with other IDE is easier.
MortenMacFly:
--- Quote from: erotavlas on November 17, 2010, 04:16:58 pm ---I can't understand why, with other IDE is easier.
--- End quote ---
...because you forgot to add the path of your files to the compiler's include directories (thus telling the compiler where to look for include files). Just add "." (the dot).
erotavlas:
Hi,
I have found the source of my problem. My description in the previous post was not completely correct...I'm sorry. If my project is like this:
--- Code: ---main.cpp
file1.h
file1.cc
data/file2.h
file3.h
--- End code ---
All works fine, but If my project is like this
--- Code: ---main.cpp
file1.h
file1.cc
data/file2.h
data1/file4.h
file3.h
--- End code ---
with #include "file4.h" inside the file file2.h, I get all the previous errors: no such file file4.h. So I can deduce that Code::block doesn't support multiple folders! Is it correct?Is there a workaround?
xunxun:
--- Quote from: erotavlas on November 17, 2010, 05:03:28 pm ---Hi,
I have found the source of my problem. My description in the previous post was not completely correct...I'm sorry. If my project is like this:
--- Code: ---main.cpp
file1.h
file1.cc
data/file2.h
file3.h
--- End code ---
All works fine, but If my project is like this
--- Code: ---main.cpp
file1.h
file1.cc
data/file2.h
data1/file4.h
file3.h
--- End code ---
with #include "file4.h" inside the file file2.h, I get all the previous errors: no such file file4.h. So I can deduce that Code::block doesn't support multiple folders! Is it correct?Is there a workaround?
--- End quote ---
If you use #include "file4.h", you should add the "." and the "./data1" to the include path.
oBFusCATed:
Most of the time "." should not be added (I think)...
The option is in Project -> Build options -> your target -> Search Paths -> Includes
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version