Page 1 of 1

Object (Intermediate) Directory Broken?

Posted: Thu Mar 25, 2010 7:50 am
by AngryDog
Hi there,

CL Version: 3.8.3833

I'm trying to set the Intermediate Directory in the project settings page. However, I find that object directories are being created in my source path and not where I specify.

For example, if I set "./obj", then I find an obj directory not only in my project root, but also under all the directories where I place source code.

Older versions of CodeLite did not do this?

How do I overcome it?

Thanks

Re: Object (Intermediate) Directory Broken?

Posted: Thu Mar 25, 2010 1:58 pm
by eranif
It is not broken.
This is the way it should work. The reason for this is to allow compilation of source files with the same name but with different path under the same project.

Imagine the following source tree:
a/a.cpp
b/a.cpp

Compiling them both in previous version of codelite will result in link error, since the compiler will generate 2 files: ./obj/a.o and .... ./obj/a.o
so one will override the other which will lead to missing symbols

Using the new method, you will get:
a/obj/a.o
b/obj/a.o

Eran

Re: Object (Intermediate) Directory Broken?

Posted: Thu Mar 25, 2010 4:21 pm
by AngryDog
Hey - Thanks for the response.

May I suggest that you consider adding a custom variable for the directory containing the source file under compilation instead. That way if you have a problem with sources files of the same name, you can set the intermediate directory to be (for example):

$(SrcFileDir)/obj

I don't have a problem with source files of the same name--I tend to avoid them for obvious reasons, but I do have a problem with obj directories appearing throughout my source code heirarchy. It's just not how I want to work--I have a place to for obj files, and CodeLite should respect that. In fact, I've resorted to using a custom makefile instead, which means that codelite has become just a text editor for me. I can see also that it could cause headaches for svn, especially with large projects.

However, I can also appreciate that with projects with multiple developers, or which build in third-party code, there may be cases were multiple files of the same name arise. However, I think this should be solveable without taking away the user's ability to specify a temporary directory.

Cheers

Andy

Re: Object (Intermediate) Directory Broken?

Posted: Thu Mar 25, 2010 7:52 pm
by pmjobin
Hi,

I agree with Andy as I've ran into the same problem. My project is built around a very specific folder structure for portability needs. I have a project folder where the project files (configured with appropriate toolchain) for each supported targets are stored in separate folders. I need to generate the object files in the target folders, otherwise, they are overwritten as each individual target is built. I successfully managed to generate object files in the target folder by removing the $(FilePath) from build settings. Unfortunately, the dependency files are still generated in the source folder and the linker also try to get object files from this folder. Consequently, the build fails.

Here is the build log:

----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "pgl_wsp.mk""
----------Building project:[ egl - Debug ]----------
mingw32-make[1]: Entering directory `W:/pgl/prj/mswin-ia32'
gcc -c "W:/pgl/src/mswin/egl.c" -g -o ./Debug/egl.o "-I../../inc" "-I."
gcc -shared -fPIC -o ../../lib/egld.so ../../src/mswin/./Debug/egl.o "-L."
gcc.exe: ../../src/mswin/./Debug/egl.o: No such file or directory
gcc.exe: no input files
mingw32-make[1]: *** [../../lib/egld.so] Error 1
mingw32-make[1]: Leaving directory `W:/pgl/prj/mswin-ia32'
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------
0 errors, 0 warnings

Attached to this post is the automatically generated makefile.

I would like to know if there is a workaround to force the linker to get the object files from the appropriate folder.

Thanks,
PMJ

Re: Object (Intermediate) Directory Broken?

Posted: Sun Mar 28, 2010 1:06 am
by pmjobin
Hi again,

Here's a little patch that adds a checkbox in the Build Settings/Build Systems pane. Unchecking "When compiling, keep source folder hierarchy for generated files" allows you to restore the old behavior.

Enjoy!
PM

Re: Object (Intermediate) Directory Broken?

Posted: Sun Mar 28, 2010 6:35 pm
by eranif
Hi PM,

I downloaded the patch and I wont apply it since it introduces back the old behavior of "all files under Debug, regardless the file name"

I know its configurable, but I prefer not to allow user to enable an option will may cause link errors (even if he has to manually enable it - which is not the case in the patch - it is enabled by default...)

I come up with a solution that may satisfy all the parties ;):

- The intermediate directory will be placed under the project directory (i.e. where the .project file exists)
- The object name will be determined by the path name.

Assuming the following directory tree:

Code: Select all

/home/eran/p/proj.propject <--- the project file
With the following files:

Code: Select all

/home/eran/p/a.cpp
/home/eran/p/b.cpp
/home/eran/p/sub/a.cpp
/home/eran/p/sub/b.cpp
/home/eran/a.cpp
/home/eran/b.cpp
The Intermediate directory will contain the following objects:

Code: Select all

/home/eran/p/Debug <--- the intermediate directory
Objects:

Code: Select all

a.o
b.o
sub_a.o
sub_b.o
eran_a.o
eran_b.o
Eran

Re: Object (Intermediate) Directory Broken?

Posted: Sun Mar 28, 2010 6:44 pm
by pmjobin
Hi Eran,

Thanks for the quick reply. Your solution seems a better one indeed. :)

Regards,
PM

Re: Object (Intermediate) Directory Broken?

Posted: Sun Mar 28, 2010 6:47 pm
by eranif
pmjobin wrote:Your solution seems a better one indeed
This fix is already committed to trunk, please update and see if it is working for you (if you are using SVN version of codelite)

Eran

Re: Object (Intermediate) Directory Broken?

Posted: Sun Mar 28, 2010 11:32 pm
by AngryDog
Cool!

Good stuff guys!

Re: Object (Intermediate) Directory Broken?

Posted: Wed Mar 31, 2010 5:31 pm
by pmjobin
eranif wrote:This fix is already committed to trunk, please update and see if it is working for you (if you are using SVN version of codelite)
I haven't tested much, but it seems to work nicely in 4020, thank you very much! :D

PM