can C::B add two file *.cpp but compile indepently because CB often ask if there were two "int main()" (even in separate two files) ?
Quote from: thanhbuu on May 18, 2012, 03:38:54 PM
can C::B add two file *.cpp but compile indepently because CB often ask if there were two "int main()" (even in separate two files) ?
Yes, the CB Project has more than one main in it. But, each target can have at most a single main in it.
Tim S.
how can I do it? Please give me some detail if I want to build/debug a file? Thanks!
Try looking under
"Project" -> "Properties"
Tab: "Build Targets"
I do not have the time to write directions.
Tim S.
Sorry but as I can see the "Build Target" is just Debug or Release. It doesn't give me a chance to select which file I need to debug step by step :) So how can I?
Add the different files in two+ different targets...
I don't get what you mean (in "two" what?). It always shows the error "multiple definition of `main'". How can I fix this using TWO file in ONE subject? That's what I mean.
What is subject in you language?
In C::B's terms we use 'project'.
What I've ment was:
1. Create a project
2. Create two targets
3. Add the first file to target1
4. Add the second file to target2
5. Build target1 or target2
6. Add virtual target to combine the two targets, so they get built together...
The same can be done with two separate projects...
I did as this tutorial to make two targets: http://wiki.codeblocks.org/index.php?title=Creating_a_new_project (http://wiki.codeblocks.org/index.php?title=Creating_a_new_project) but it shows this error:
mingw32-g++.exe: error: unrecognized option '-shared-libstdc++'
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
how can I fix it?
Remove the option...
again it shows "multiple definition of `main'"
Then you have two main functions in two files compiled together.
Please read this: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
And make sure you understand it!
Quote from: thanhbuu on May 18, 2012, 06:40:51 PM
how can I do it? Please give me some detail if I want to build/debug a file? Thanks!
The fastest way is to use a separate project for each file; that will work for you.
My answer of using separate targets was to your original question (of compiling two files with main in each); I have no idea if debugging will work right with separate targets.
Tim S.
Quote from: stahta01 on May 19, 2012, 04:02:28 PM
Quote from: thanhbuu on May 18, 2012, 06:40:51 PM
how can I do it? Please give me some detail if I want to build/debug a file? Thanks!
The fastest way is to use a separate project for each file; that will work for you.
My answer of using separate targets was to your original question (of compiling two files with main in each); I have no idea if debugging will work right with separate targets.
Tim S.
If the compiler-settings are correct, it will work, because you can debug one target and ignore the other one.
Anybody can do this (according to the tutorial as I mentioned or by your experience), can you post a video of the process so that everybody know this process? Thanks!