User forums > Using Code::Blocks

Copying object files from one folder to another one during compiling process

(1/2) > >>

pozzugno:
My project has the following folderds:
<main_dir>\project.cbp
<main_dir>\src\main.c
<main_dir>\src\f1\f1.c
<main_dir>\src\f2\f2.c

For a strange reason (if you're curious I can tell you about) I need to store all object files in <main_dir>\OBJ folder, before linking. In other words, after compiling process the object files should be located in:
<main_dir>\obj\main.obj
<main_dir>\obj\f1.obj
<main_dir>\obj\f2.obj

Unfortunately, if I set <main_dir\obj folder as the output object folder in the project configuration settings, I have:
<main_dir>\obj\main.obj
<main_dir>\obj\f1\f1.obj
<main_dir>\obj\f2\f2.obj

I was thinking to copy object files from one folder to another one with post-build steps, but I think it's not possible to execute a command after each file compilation, only after linking process.

Another solution could be to change the compiler command from
  $compiler $options $includes -o $object -c $file
to
  $compiler $options $includes -o $objects_output_dir/$file_name.obj -c $file
But in this way the make process doesn't work. CodeBlocks compiles source files every time, even if they aren't changed since the last compilation time, because it couldn't find the object file where he supposed to be.

Any suggestions?

Jenna:

--- Quote from: pozzugno on December 06, 2010, 01:33:17 pm ---Any suggestions?

--- End quote ---

Try "Settings -> Compiler and debugger... -> [the compiler you use] -> Other settings -> Advanced options... -> Others -> Use flat objects:"
"Other settings might be hidden (it's the right-most tab) and after you clicked "Advanced options" you have to answer with "Yes".

pozzugno:

--- Quote from: jens on December 06, 2010, 02:41:06 pm ---Try "Settings -> Compiler and debugger... -> [the compiler you use] -> Other settings -> Advanced options... -> Others -> Use flat objects:"

--- End quote ---
Good! It worked for me as I want.  :D

There's just a small strange behaviour. After compilation, I'll have many empty folders under OBJ directory:
  <main_dir>\obj\f1
  <main_dir>\obj\f2
but the object files are all in <main_dir>\obj.
If I delete the obj folder (with all the sub-folders), after compilation I have again the directory structure.

Jenna:
I noticed it too.
I never used flat objects before.
I will look into it.

killerbot:
the flat objects work (I added that feature), those dirs are still created, I think they are created earlier in the build process. I didn't look into it any furhter back in the days, since i got the object files where I wanted them to show up, all next one another, nicely flat ;-)

Navigation

[0] Message Index

[#] Next page

Go to full version