NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

C/C++: multiple executables within the project

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Stas Torgashov
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 8:19 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Hello,

I'm working on a C++ project. And I need to build several executables in the
same project. Now I have to create several projects with shared source
folders to do this. But, maybe, there is a way to have several executable
built within the single project. Is it possible? Does anybody know how I can
make it?
Thanks in advance for suggestions,

--
73!
Stas Torgashov aka Crimson Cat
Back to top
Gordon Prieur
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 8:46 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon


Stas Torgashov wrote:
Quote:
Hello,

I'm working on a C++ project. And I need to build several executables in the
same project. Now I have to create several projects with shared source
folders to do this. But, maybe, there is a way to have several executable
built within the single project. Is it possible? Does anybody know how I can
make it?
Thanks in advance for suggestions,

Back to top
Stas Torgashov
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 9:40 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Gordon,

Could you, please, give an example how I can make this?
Do I need to setup some options manually rather than setting the proper files
list?


Quote:
Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon

Stas Torgashov wrote:
Quote:
Hello,

I'm working on a C++ project. And I need to build several executables in
the same project. Now I have to create several projects with shared
source folders to do this. But, maybe, there is a way to have several
executable built within the single project. Is it possible? Does anybody
know how I can make it?
Thanks in advance for suggestions,



--
73!
Stas Torgashov aka Crimson Cat
Back to top
Gordon Prieur
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 10:11 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Stas,

I just did this with an Arguments sample project. I modified args.c
so it looked
like the following:

Quote:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
int i;

// Prints arguments
printf("Arguments:\n");
#ifdef BACKWORDS
for (i = argc - 1; i > 0; i--)
#else
for (i = 0; i < argc; i++)
#endif
{
printf("%i: %s\n", i, argv[i]);
}

return 0;
}

Then I right clicked on the project node and selected Properties and clicked
the Manage Configurations button near the top. My (default) configuratino
was Debug, so I pressed Copy and then Rename (and named in Backwards).

After OK'ing the Manage Configurations dialog I selected the C Compiler
category in the hand pane of Project Properties. Then I set Configuration to
"Backwards" and added "-DBACKWORDS=1" to the Additional Options
field. Next, I pressed the Linker category and cnaged the Output from "args"
to "bargs" and pressed OK.

At that point, if I ran with the Debug configuration I got args displaying
1 - n. If I switched to the Backwards configuraion I ran bargs which
displays backfwards.

To build both (or all) configurations, right click on the project node and
select Batch Build. In my case I see 3 configuration, the 2 default ones
(Debug and Release) and the Backwards one I defined.

Gordon


Stas Torgashov wrote:
Quote:
Gordon,

Could you, please, give an example how I can make this?
Do I need to setup some options manually rather than setting the proper files
list?



Quote:
Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon

Stas Torgashov wrote:

Quote:
Hello,

I'm working on a C++ project. And I need to build several executables in
the same project. Now I have to create several projects with shared
source folders to do this. But, maybe, there is a way to have several
executable built within the single project. Is it possible? Does anybody
know how I can make it?
Thanks in advance for suggestions,




Back to top
Stas Torgashov
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 10:45 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Gordon,

I've got what you mean.
This way is applicable when you have one main file. But I have several source
files (each has its own main() function), which are to be compiled to produce
separate executables within the single project.

Quote:
Stas,

I just did this with an Arguments sample project. I modified args.c
so it looked

like the following:
Quote:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
int i;

// Prints arguments
printf("Arguments:\n");
#ifdef BACKWORDS
for (i = argc - 1; i > 0; i--)
#else
for (i = 0; i < argc; i++)
#endif
{
printf("%i: %s\n", i, argv[i]);
}

return 0;
}

Then I right clicked on the project node and selected Properties and
clicked the Manage Configurations button near the top. My (default)
configuratino was Debug, so I pressed Copy and then Rename (and named in
Backwards).

After OK'ing the Manage Configurations dialog I selected the C Compiler
category in the hand pane of Project Properties. Then I set Configuration
to "Backwards" and added "-DBACKWORDS=1" to the Additional Options
field. Next, I pressed the Linker category and cnaged the Output from
"args" to "bargs" and pressed OK.

At that point, if I ran with the Debug configuration I got args displaying
1 - n. If I switched to the Backwards configuraion I ran bargs which
displays backfwards.

To build both (or all) configurations, right click on the project node and
select Batch Build. In my case I see 3 configuration, the 2 default ones
(Debug and Release) and the Backwards one I defined.

Gordon

Stas Torgashov wrote:
Quote:
Gordon,

Could you, please, give an example how I can make this?
Do I need to setup some options manually rather than setting the proper
files list?

Quote:
Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon

Stas Torgashov wrote:
Quote:
Hello,

I'm working on a C++ project. And I need to build several executables
in the same project. Now I have to create several projects with shared
source folders to do this. But, maybe, there is a way to have several
executable built within the single project. Is it possible? Does
anybody know how I can make it?
Thanks in advance for suggestions,



--
73!
Stas Torgashov aka Crimson Cat
Back to top
Gordon Prieur
Posted via mailing list.





PostPosted: Fri Oct 03, 2008 11:36 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Stas,

You have to individually set properties on each file, not just on
the project
(thats the step I couldn't remember). In the Arguments example you'd open
the Source Files folder and right click on args.c and select Properties.
In this
panel there is an Excluded From Build toggle. Set the Configuration and the
toggle accordingly.

Its not a very user friendly model, but should work for small
projects or
large projects with only a few different files.

Gordon


Stas Torgashov wrote:
Quote:
Gordon,

I've got what you mean.
This way is applicable when you have one main file. But I have several source
files (each has its own main() function), which are to be compiled to produce
separate executables within the single project.


Quote:
Stas,

I just did this with an Arguments sample project. I modified args.c
so it looked

like the following:

Quote:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
int i;

// Prints arguments
printf("Arguments:\n");
#ifdef BACKWORDS
for (i = argc - 1; i > 0; i--)
#else
for (i = 0; i < argc; i++)
#endif
{
printf("%i: %s\n", i, argv[i]);
}

return 0;
}

Then I right clicked on the project node and selected Properties and
clicked the Manage Configurations button near the top. My (default)
configuratino was Debug, so I pressed Copy and then Rename (and named in
Backwards).

After OK'ing the Manage Configurations dialog I selected the C Compiler
category in the hand pane of Project Properties. Then I set Configuration
to "Backwards" and added "-DBACKWORDS=1" to the Additional Options
field. Next, I pressed the Linker category and cnaged the Output from
"args" to "bargs" and pressed OK.

At that point, if I ran with the Debug configuration I got args displaying
1 - n. If I switched to the Backwards configuraion I ran bargs which
displays backfwards.

To build both (or all) configurations, right click on the project node and
select Batch Build. In my case I see 3 configuration, the 2 default ones
(Debug and Release) and the Backwards one I defined.

Gordon

Stas Torgashov wrote:

Quote:
Gordon,

Could you, please, give an example how I can make this?
Do I need to setup some options manually rather than setting the proper
files list?


Quote:
Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon

Stas Torgashov wrote:

Quote:
Hello,

I'm working on a C++ project. And I need to build several executables
in the same project. Now I have to create several projects with shared
source folders to do this. But, maybe, there is a way to have several
executable built within the single project. Is it possible? Does
anybody know how I can make it?
Thanks in advance for suggestions,




Back to top
kalyanji



Joined: 24 Sep 2008
Posts: 4

PostPosted: Sat Oct 04, 2008 5:39 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Hi,


I am completely new to Netbeans. I am working on Netbeans
6.0.1 c/c++ IDE in ubuntu. I can successfully compile and run a project
only if it contains single source file.

issue:


I created more than one source file in the same project
and compiled individual files successfully later on i am not able to
run and create output for individual files.

I got a few replies to this issue earlier but i was
able to follow those instruction partially, i have no clue how to
change args to bargs.. What was listed in that mail was difficult for
me to follow.

Could anyone send step by step procedure to me please
because i am novice.


Thanks for your time & reply
kalyan
Back to top
Stas Torgashov
Posted via mailing list.





PostPosted: Sat Oct 04, 2008 6:57 pm    Post subject: C/C++: multiple executables within the project Reply with quote

Hello,

Thanks, I've got the idea. Will try on my project.

Quote:
Stas,

You have to individually set properties on each file, not just on
the project
(thats the step I couldn't remember). In the Arguments example you'd open
the Source Files folder and right click on args.c and select Properties.
In this
panel there is an Excluded From Build toggle. Set the Configuration and the
toggle accordingly.

Its not a very user friendly model, but should work for small
projects or
large projects with only a few different files.

Gordon

Stas Torgashov wrote:
Quote:
Gordon,

I've got what you mean.
This way is applicable when you have one main file. But I have several
source files (each has its own main() function), which are to be compiled
to produce separate executables within the single project.

Quote:
Stas,

I just did this with an Arguments sample project. I modified args.c
so it looked

like the following:
Quote:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
int i;

// Prints arguments
printf("Arguments:\n");
#ifdef BACKWORDS
for (i = argc - 1; i > 0; i--)
#else
for (i = 0; i < argc; i++)
#endif
{
printf("%i: %s\n", i, argv[i]);
}

return 0;
}

Then I right clicked on the project node and selected Properties and
clicked the Manage Configurations button near the top. My (default)
configuratino was Debug, so I pressed Copy and then Rename (and named in
Backwards).

After OK'ing the Manage Configurations dialog I selected the C Compiler
category in the hand pane of Project Properties. Then I set
Configuration to "Backwards" and added "-DBACKWORDS=1" to the Additional
Options field. Next, I pressed the Linker category and cnaged the Output
from "args" to "bargs" and pressed OK.

At that point, if I ran with the Debug configuration I got args
displaying 1 - n. If I switched to the Backwards configuraion I ran
bargs which displays backfwards.

To build both (or all) configurations, right click on the project node
and select Batch Build. In my case I see 3 configuration, the 2 default
ones (Debug and Release) and the Backwards one I defined.

Gordon

Stas Torgashov wrote:
Quote:
Gordon,

Could you, please, give an example how I can make this?
Do I need to setup some options manually rather than setting the proper
files list?

Quote:
Stas,

The only way to do this in a single C++ project is to create
multiple configurations,
each one building a different executable. You can use the batch build
feature to build
all at the same time (or to choose which to build).

Gordon

Stas Torgashov wrote:
Quote:
Hello,

I'm working on a C++ project. And I need to build several executables
in the same project. Now I have to create several projects with
shared source folders to do this. But, maybe, there is a way to have
several executable built within the single project. Is it possible?
Does anybody know how I can make it?
Thanks in advance for suggestions,



--
73!
Stas Torgashov aka Crimson Cat
Back to top
Gordon Prieur
Posted via mailing list.





PostPosted: Sun Oct 05, 2008 5:00 am    Post subject: C/C++: multiple executables within the project Reply with quote

Kalyan,

You're problem may be that you're compiling individual files (at
least thats what you said you were doing). If you create a C/C++
application project then each file you add to this project will get
compiled and linked. If you individually compile files then no
link step will be done.

The basic project actions are Build, Clean & Build, Run, and Debug.
If you explicitly compile individual files, you're probably doing more
than you want to.

Also, the args/bargs issue is something completely different than
what you're doing. Sometimes you want to have a project which
can create more than 1 executable in some circumstances. Thats
what the bargs/args issue was about. While Stas didn't say what he
was doing, the most common (although not the only reason) reason
for doing this is to add tests to a project. But this isn't a novice issue
and probably not something which will help you now...

Gordon


address-removed wrote:
Quote:



Hi,


I am completely new to Netbeans. I am working on Netbeans
6.0.1 c/c++ IDE in ubuntu. I can successfully compile and run a
project only if it contains single source file.

issue:


I created more than one source file in the same
project and compiled individual files successfully later on i am not
able to run and create output for individual files.

I got a few replies to this issue earlier but i was
able to follow those instruction partially, i have no clue how to
change args to bargs.. What was listed in that mail was difficult for
me to follow.

Could anyone send step by step procedure to me please
because i am novice.


Thanks for your time & reply
kalyan
Back to top
kalyanji



Joined: 24 Sep 2008
Posts: 4

PostPosted: Sun Oct 05, 2008 7:01 am    Post subject: C/C++: multiple executables within the project Reply with quote

Gordon,


Thanks for your advise. But as i told you that i am
netbeans beginner and completely lost here.



First of all i had created a project with only one source file then
compiled and ran that successfully.

Later i created another .c file in the same project under source files
and this file was compiled successfully but i am still not able to run
project now.

So is there any simpler way that i can create more than one .c files in
the same project and get them compile and run successfully.

I was not successful in linking the second file i created and run main
project after going through the reply you have sent to me.


Thanks for your time

kalyan




-----Original Message-----
From: Gordon Prieur <address-removed>
To: address-removed
Sent: Sun, 5 Oct 2008 10:29 am
Subject: Re: [nbusers] C/C++: multiple executables within the project






Kalyan, 
 

  You're problem may be that you're compiling individual files (at 

least thats what you said you were doing). If you create a C/C++ 

application project then each file you add to this project will get 

compiled and linked. If you individually compile files then no 

link step will be done. 
 

  The basic project actions are Build, Clean & Build, Run, and Debug. 

If
you explicitly compile individual files, you're probably doing more 

than you want to. 
 

  Also, the args/bargs issue is something completely different than 

what you're doing. Sometimes you want to have a project which 

can create more than 1 executable in some circumstances. Thats 

what the bargs/args issue was about. While Stas didn't say what he 

was doing, the most common (although not the only reason) reason 

for doing this is to add tests to a project. But this isn't a novice
issue 

and probably not something which will help you now... 
 

Gordon 
 


address-removed wrote: 

Quote:
 

Quote:
 

Quote:
 

Quote:
Hi, 

Quote:
 

Quote:
 

Quote:
I am completely new to Netbeans. I am working on Netbeans
6.0.1 c/c++ IDE in ubuntu. I can successfully compile and run a
project only if it contains single source file. 

Quote:
 

Quote:
issue: 

Quote:
 

Quote:
 

Quote:
I created more than one source file in the same
project and compiled individual files successfully later on i am not
able to run and create output for individual files. 

Quote:
 

Quote:
I got a few replies to this issue earlier but i was
able to follow those instruction partially, i have no clue how to
ch
ange args to bargs.. What was listed in that mail was difficult for
Quote:
me to follow. 

Quote:
 

Quote:
Could anyone send step by step procedure to me please
because i am novice. 

Quote:
 

Quote:
 

Quote:
Thanks for your time & reply 

Quote:
kalyan 
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo