Author Topic: How to add files to project  (Read 11321 times)

Offline JasonW

  • Single posting newcomer
  • *
  • Posts: 2
How to add files to project
« on: February 27, 2013, 10:12:29 pm »
Hi,
This would seem like the easiest thing to do, but I can't figure out how to add files to the project.

When I go to Project->Add files it gives me a file dialog box with existing files in the Project folder. So let's say I'm trying to add "menu.h" to the Project I select it, press Open (a little suspicious here because it should say "Add" or "Add to Project"). So it then brings up a little menu that says "Select the targets this file should belong to..." with Debug and Release preselected. I leave those at the default then click OK, and the menu disappears. And....

Nothing happens. When I go to compile the project it is stopping at the #include <menu.h> statement saying "No such file or directory" which is classic behavior of the compiler not "seeing" the file because it hasn't been added.

And besides, in most IDEs I've used, you don't have to add resource files from the outside as I've had to do here because the "Add files" functionality allows you to create files internally.

It's all very strange behavior making me wonder if this isn't a bug of some kind.

Or maybe there is another way of adding files to the project. No search has brought up this problem as I've encountered it.

Thanks for any feedback...
 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: How to add files to project
« Reply #1 on: February 27, 2013, 10:17:46 pm »
Nothing happens. When I go to compile the project it is stopping at the #include <menu.h> statement saying "No such file or directory" which is classic behavior of the compiler not "seeing" the file because it hasn't been added.
And this is the classic example of a user not knowing how to compile c++ projects!

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: How to add files to project
« Reply #2 on: February 28, 2013, 06:02:32 am »
It's not as strange as it seems to be, JasonW. The file had really been added to your project but your (project) INCLUDE path had not been modified. If the header was not on the path, the compiler will not find it. You will get "no such file" complaint.

You have added the file correctly to the project but you also need to add the directory of the header to the path. You do it in "Project Options -> Compiler -> Search Directories". This is nothing strange: in any IDE, you need to keep your compiler informed, where are your headers. As far as creating new files from the IDE is concerned, try "New -> Empty File".

Offline JasonW

  • Single posting newcomer
  • *
  • Posts: 2
Re: How to add files to project
« Reply #3 on: March 03, 2013, 05:17:35 pm »
Thanks for the replies. Yes, I've figured out how to add files. No problem.