views:

31

answers:

3

Hello. I am somewhat of a novice and am seeking some help.

I am working in Visual Studios 2010 and have my solution that has my project that I am currently working on. Specifically I am working on a Win32 Project. I don't know if that is important to know or not.

I have made a file/folder structure in the directory I am working on to help organize my sources. I would like to mimic that in the project but can't. After organizing my sources it says that some can't be found when I compile. I have alleviated some of the problem by editing some of the #include statements but there are still some I can't fix as they need to include a file from one folder higher (I guess the parent folder?) and I don't know how to do that in an include statement.

Is there anyway I can have actual physical folders in my project that mimic my structure? If so will it handle the #includes fine? (IE if I say #include "BaseClass.h" and its in the folder one higher (again I guess parent folder?) will it find it?).

I've tried dragging my files/folders over from the solution explorer but it just adds them. I have also tried to use the Add New Filter (it has a folder icon) and it does indeed create a "folder" in the project but they aren't physical folders. They are just there to help organize the files in the Solution Explorer for the project.

I've tried Google searching:

create folder visual studio 2010 project add folder visual studio 2010 project create file structure visual studio 2010 project

And they just direct me to drag over the folders from my Solution Explorer and again they don't actually add the folders. They do speak of a template but I don't know if thats what I need to do. I am not technically skilled enough yet to understand it all so would need to do more research. Any pointers/help would be much appreciated.

A: 

In the solution explorer, right click and choose Add Project Folder (or something similar, I don't have VS available to view right now). You shouldn't move the files in Explorer after they have been created in VS, as it will affect all the references.

Whenever possible, perform all file moves/renames/changes within the VS IDE.

Jaymz
Hmmm... I've tried this and it adds it just to the solution. Even then I don't see the folder physically show up.
Chris
A: 

You can fix failure to include by appending ";.." (this means "one level up from here") to the list of include paths to check. Right click 'Project', select 'Properties', locate 'C/C++', 'General', 'Additional Include Directories'. Make sure you do this for both Debug and Release configurations.

I've always found relating Visual Studio folder structure in Solution Explorer to the physical files painful, so I generally avoid this.

Steve Townsend
So then you don't have any physical file structure and just put all your sources in one spot on your hard drive?
Chris
@Chris - no, I just don't have folder structure in Solution Explorer. There's nothing to stop you adding files from > 1 location to a project. I am sure that not everybody is going to like this - perhaps someone else can advise on working usage. My main concern was to get your includes fixed up in the short term.
Steve Townsend
A: 

So you have some structure on the file system

A
 A.sln
 A.prj
 A.h
 Base
  B.cpp
  B.h
  Derived
   C.cpp
   C.h
   D.cpp
   D.h
 SomeOther
  E.h

C and D can refer to B in various ways
#include "../B.h"
or
changing the project settings to add to the include folder list "Base" then
#include "B.h"

C and D could also refer to A #include "../../A.h"
or SomeOther #include "../../SomeOther/E.h"

'..' in a path indicates to go up one parent
prefer unix style '/' to windows style '\' for portability, but either will work.

Be cautious with structure, MSVC doesn't help you manage it like eclipse helps manage packages in Java, it can become more of a hassle than a help if you make too many small folders.

Greg Domjan