Author Topic: Placement of .obj files  (Read 261 times)

Offline Cool Javelin

  • Multiple posting newcomer
  • *
  • Posts: 19
Placement of .obj files
« on: April 30, 2019, 09:59:31 am »
Win7 32bit, C::B 16

How do I get all .obj files to end up in the same folder as their respective .c files?

I have a folder I keep a few utility .c files I have created that I include in most of my projects.

If my project is in drive N, and I include a file from C:\Users\Mark\Documents\Programming\C_progs\Include, I get a corresponding path from my project folder with the same name, sans the actual colon.

So if my project is in N:\Customers\Accounting\Utilities\, the subsequent .o ends up in
N:\Customers\Accounting\Utilities\.C\Users\Mark\Documents\Programming\C_progs\Include.

Of course this is really unacceptable.

What I want is for the .o files to be in the include folder where the .c file is.
In this way, if I compile a c support file in another project, it won't have to be compiled again in this project.

Thanks for any help on this,
Mark.
« Last Edit: April 30, 2019, 10:20:48 am by Cool Javelin »
Love to program the old way.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11714
    • Travis build status
Re: Placement of .obj files
« Reply #1 on: April 30, 2019, 10:56:05 am »
Do you use C::B projects?
(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 sodev

  • Regular
  • ***
  • Posts: 255
Re: Placement of .obj files
« Reply #2 on: April 30, 2019, 02:04:56 pm »
What you are trying to do is quite a bad idea. You dont only want to do an In-Tree build instead of an Out-of-Tree build which complicates the clean up to get a clean rebuild but also want to share the compilation results between different projects.

That does not only couple these projects but also requires that all projects are compiled with identical compiler settings and, especially if this shared code depends directly or indirectly on defines, the same set of defines. Especially that last requirement is quite risky and hard to ensure. If you fail to do so you will get obscure and extremely hard to debug errors.

If you want to share code, either turn that shared code into a library and include that into your projects as binary or include it on source level by means of your vcs like svn externals or git submodules.

Offline Cool Javelin

  • Multiple posting newcomer
  • *
  • Posts: 19
Re: Placement of .obj files
« Reply #3 on: May 01, 2019, 10:32:03 am »
Good idea or bad, Having to link all projects together, all those things...

All I want is the ability to make C::B put the .o file in the same folder as it's .c file.

Is that possible? And how to do it?

Thanks, Mark.
Love to program the old way.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11714
    • Travis build status
Re: Placement of .obj files
« Reply #4 on: May 01, 2019, 10:44:32 am »
It depends. On the answers of the following questions:
1. Do you have a project?
2. Are you prepared to write a makefile, cmake, mason, etc..?
3. You can probably use a post build step

The internal build system always places the .o files in .obj/obj folder inside your project dir tree.
Generally the path of each object file is predictable and you can copy it to where you want it in a post build.
(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 Cool Javelin

  • Multiple posting newcomer
  • *
  • Posts: 19
Re: Placement of .obj files
« Reply #5 on: May 02, 2019, 04:59:46 am »
I do have a project, several in fact. Most use that common include I mentioned.

I have never written a make file, I guess I can learn how,

The idea of using a post build step is doable.

Thanks,
Mark.
« Last Edit: May 02, 2019, 07:31:23 am by Cool Javelin »
Love to program the old way.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11714
    • Travis build status
Re: Placement of .obj files
« Reply #6 on: May 02, 2019, 10:36:54 am »
Why don't you create a static library project for the common code?
A static library is just an archive with some .o files.
(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!]