Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Create multiple projects inside a single project

Question posted by: nightscorpion (Newbie) on July 25th, 2008 11:59 AM
Hello ,
I have two projects A and B
is it possible to import project B in project A?
if not is there any alternative ?

i tried to import project B as a subfolder. but since both the projects are in different namespaces project A doesnt recognise the namespace from Project B
and since each of the projects contain a lot of files it is time consuming to change the namespaces fin each of the files.

any suggestions would be very helpfull
Banfa's Avatar
Banfa
AdministratorVoR
5,044 Posts
July 25th, 2008
12:05 PM
#2

Re: Create multiple projects inside a single project
Without knowing what piece of software you are using your question is going to be impossible to answer.

Reply
r035198x's Avatar
r035198x
Administrator
10,754 Posts
July 25th, 2008
12:21 PM
#3

Re: Create multiple projects inside a single project
You want to do this both in C++ and C#/VB?

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 27th, 2008
09:30 AM
#4

Re: Create multiple projects inside a single project
sorry i posted my question at the wrong place.. i was asking this question based on visual studio c#

Reply
Banfa's Avatar
Banfa
AdministratorVoR
5,044 Posts
July 27th, 2008
10:43 AM
#5

Re: Create multiple projects inside a single project
OK in Visual Studio (C/C++, C#, VB, SQL Database and all other projects) you can not have projects inside other projects.

You have a Solution (or Workspace in VS 6.0 parlance) you add all you projects to the Solution. If the projects have dependencies on each other then you can set that with project dependencies and VS will then sort out building them in the right order.

To start with if you are using VS 2005 C++ I find it useful to switch on the "Always show solution" option, this is in "Menu->Options..." then in the "Projects and Solutions" tree item. This is not required in VS 2005 C# because it doesn't have that option and it is always on.

To add an existing project to your soltuion

Right click on the Solution in the "Solution Explorer" and then select "Add->Existing Project ..." or select "Add->New Project ..." to add a new project.

Once you have more than 1 project in your solution then right click the project in the solution explorer and select "Project Dependencies ...". In the displayed dialog you can select which prohjects depend on which other projects.

Of course if one or more of you projects are class libraries to be used by the other projects then you will want to add them to the references of the projects that use them. Either right click the project and select "Add References ..." or expanded the project, right click the "References" folder and select "Add References ...". In the box that appears select the "Projects" tabs to add references from other projects that appear in you solution. This will then handle building the project and all its references for debug or release for you as required.

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 27th, 2008
03:08 PM
#6

Re: Create multiple projects inside a single project
ok thanx a lot for ur reply..actually i earlier had 2 separate projects in a solution and both projects were depending on each other so i was getting a circular dependency.in order to prevent this circular dependendy..i was trying to combine both the projects in one as in eclipse.. but i guess since i cannot combine both the projects in one i need to go back to my earlier thinking thanx a lot for your reply...

Reply
Banfa's Avatar
Banfa
AdministratorVoR
5,044 Posts
July 27th, 2008
04:33 PM
#7

Re: Create multiple projects inside a single project
A circular dependency is indicative of a design flaw and putting the boundaries between you assemblies in the wrong place.

However if you wanted the 2 projects as 1 just include all the source into a single project.

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 27th, 2008
06:54 PM
#8

Re: Create multiple projects inside a single project
hello,
i have also tried to put the source files from the 2nd project(which are having a different namespace) in the first one but as a sub folder .

but the problem is my main project cannot recognise the source files from this subfolder since they are having a different namespace..

is it possible in visual studio to work with 2 different namespaces in a single project?

Reply
Banfa's Avatar
Banfa
AdministratorVoR
5,044 Posts
July 27th, 2008
07:22 PM
#9

Re: Create multiple projects inside a single project
Yes, after you have include the headers into the file just put

using namespace <YourNameSpace>;

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 28th, 2008
07:43 AM
#10

Re: Create multiple projects inside a single project
Hello,
thank you..i succeeded so far..now i am able to import the source files from the folder .
However this folder again contains sub folders and these subfolders contain image (.bmp) files and i do not know how to gain access to these source files from the sub folders.
i tried it out with
private <subfolder>.<sourcefile> but unfortunately it doesnt work that way.

would be gratefull for any help provided

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 28th, 2008
07:49 AM
#11

Re: Create multiple projects inside a single project
sorry..thought i solved the problem but it isnt solved yet.. :(

Reply
nightscorpion's Avatar
nightscorpion
Newbie
18 Posts
July 28th, 2008
10:18 AM
#12

Re: Create multiple projects inside a single project
Hello,
i solved the problem with the namespaces..thanx a lot guys for ur help

regards
sonia

Reply
Reply
Not the answer you were looking for? Post your question . . .
190,079 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top C / C++ Forum Contributors