Code::Blocks Forums

User forums => Help => Topic started by: zrno on July 21, 2012, 04:36:52 pm

Title: Compiling (building) - order of, exclude from etc.
Post by: zrno on July 21, 2012, 04:36:52 pm
Hi,

I started using CodeBlocks three days ago and love it. But, I haven't been able to figure out one really simple thing - how does compiling of projects with multiple files work? Do I need to right-click every file and uncheck "compile file" and "link file"? I have A LOT of files I'd like to import from VS and it's gonna be a huge pain in the butt if I have to do it that way.
Title: Re: Compiling (building) - order of, exclude from etc.
Post by: oBFusCATed on July 21, 2012, 04:50:59 pm
.cpp/.c/.d files are compiled and linked by default, you just have to add them to the project.
Title: Re: Compiling (building) - order of, exclude from etc.
Post by: zrno on July 21, 2012, 05:13:27 pm
Damn, I just realized how stupid my post was  ;D

What I meant to write was how do I set files so that they don't compile? I've imported some files from VS and I keep getting the "multiple definition of main" error, and if I only import one file, it works. All the files work in VS, so it leads me to believe that the problem is all of them are set to be compiled. So, I need to set them all (except one) to not compile.

Title: Re: Compiling (building) - order of, exclude from etc.
Post by: oBFusCATed on July 21, 2012, 05:45:54 pm
As far as I know there is no difference between VS and C::B in this regard.

Probably you can use multiple targets and to add only the files need for a particular target.
Title: Re: Compiling (building) - order of, exclude from etc.
Post by: zrno on July 21, 2012, 06:01:47 pm
Well, I added the files, but they are all set to compile by default, and that causes errors. How do I set them all not to compile in one go? Otherwise I have to right click on each file and set it to not compile.
Title: Re: Compiling (building) - order of, exclude from etc.
Post by: oBFusCATed on July 21, 2012, 06:47:15 pm
1. Remove them all.
2. Add one target per executable
3. Add files for executable0 and in the target select dialog select the target for the executable
4. Repeat 3 for all executables

Another option is to use multiple projects.

p.s. how does VS compile it correctly if you have two main functions?
Title: Re: Compiling (building) - order of, exclude from etc.
Post by: Jenna on July 21, 2012, 06:54:48 pm
Did you try the project/workspace importer for VS ?