Author Topic: Compiling (building) - order of, exclude from etc.  (Read 7658 times)

Offline zrno

  • Single posting newcomer
  • *
  • Posts: 3
Compiling (building) - order of, exclude from etc.
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12121
    • Travis build status
Re: Compiling (building) - order of, exclude from etc.
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline zrno

  • Single posting newcomer
  • *
  • Posts: 3
Re: Compiling (building) - order of, exclude from etc.
« Reply #2 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.


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12121
    • Travis build status
Re: Compiling (building) - order of, exclude from etc.
« Reply #3 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline zrno

  • Single posting newcomer
  • *
  • Posts: 3
Re: Compiling (building) - order of, exclude from etc.
« Reply #4 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12121
    • Travis build status
Re: Compiling (building) - order of, exclude from etc.
« Reply #5 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Compiling (building) - order of, exclude from etc.
« Reply #6 on: July 21, 2012, 06:54:48 pm »
Did you try the project/workspace importer for VS ?