Object (Intermediate) Directory Broken?

CodeLite installation/troubleshooting forum
AngryDog
CodeLite Curious
Posts: 4
Joined: Wed Mar 24, 2010 9:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Object (Intermediate) Directory Broken?

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
Make sure you have read the HOW TO POST thread
AngryDog
CodeLite Curious
Posts: 4
Joined: Wed Mar 24, 2010 9:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
pmjobin
CodeLite Enthusiast
Posts: 15
Joined: Thu Mar 25, 2010 7:28 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
You do not have the required permissions to view the files attached to this post.
pmjobin
CodeLite Enthusiast
Posts: 15
Joined: Thu Mar 25, 2010 7:28 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
Make sure you have read the HOW TO POST thread
pmjobin
CodeLite Enthusiast
Posts: 15
Joined: Thu Mar 25, 2010 7:28 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post by pmjobin »

Hi Eran,

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

Regards,
PM
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
Make sure you have read the HOW TO POST thread
AngryDog
CodeLite Curious
Posts: 4
Joined: Wed Mar 24, 2010 9:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post by AngryDog »

Cool!

Good stuff guys!
pmjobin
CodeLite Enthusiast
Posts: 15
Joined: Thu Mar 25, 2010 7:28 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Object (Intermediate) Directory Broken?

Post 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
Post Reply