User forums > Using Code::Blocks
Redirecting Object Files
(1/1)
muppetjones:
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!
muppetjones:
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()'|
--- End code ---
Even though it finds the *.h file which is in the same directory as the *.o file and the *.cpp!!
What am I missing?!
MortenMacFly:
--- Quote from: muppetjones on November 13, 2009, 08:38:09 pm ---What am I missing?!
--- End quote ---
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.
Navigation
[0] Message Index
Go to full version