Author Topic: Redirecting Object Files  (Read 4400 times)

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Redirecting Object Files
« on: November 13, 2009, 07:27:21 pm »
How do you redirect the location of _some_ of your object files?

This is a (slight) continuation of the problem found here:
http://forums.codeblocks.org/index.php/topic,11508.msg78392.html#msg78392

The run down: For organizational purposes, I have a lib folder and a projects folder (using ~ for brevity):

~/lib/
~/projects/

I want my *.cpp, *.h, *.o files in the lib folder (i.e. ~/lib/bStat/bStat.o) and the project files in the project folder (i.e. ~/projects/bStat/bStat.cbp).

If I change my objects output dir (Projects > Properties > Build target > ), to handle this, it also moves my main.o file (which makes sense). The problem arises since the paths follow the same pattern for all projects, meaning the main.o for each project is in the same place. As is obvious, it means that whenever I compile a new program, it'll use the main.o for the last compiled project unless I delete the previous main.o.

Does anyone know of a workaround or of a good solution to this? I know I could manually curate the files, but that is tedious.

Any help is appreciated!

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Redirecting Object Files
« Reply #1 on: November 13, 2009, 08:38:09 pm »
I found half of a solution -- it's not perfect but it's better than nothing. If anyone else has other ideas, _please_ let me know =).

Settings > Compiler and Debugger > Other (tab) > Advanced > Others (tab) > Use Flat Objects

This puts all of the *.o files into the top level directory. Not perfect, but it's better than nothing =).


However, this still does not fix the problem. I still get
Code
/home/muppetjones/Ubuntu One/projects/test/main.cpp|9|undefined reference to `bStat::bStat()'|
Even though it finds the *.h file which is in the same directory as the *.o file and the *.cpp!!

What am I missing?!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Redirecting Object Files
« Reply #2 on: November 13, 2009, 08:45:06 pm »
What am I missing?!
Basic programming skills.

You not only need to compile your main file, but also all other *.cpp files of relevance. In what file is the *implementation* (not the definition) of "bStat::bStat()"? Add this source file to your project to have it compiled/linked to your target executable. Please read about how a compiler/linker works and try to compile your program on the command line. This will make you understand how a compiler/linker works and will enable you to setup your project correct.

However - this is not a general programming forum so I lock this topic now as it violates our forum rules. It's not related to C::B any longer.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ