User forums => Using Code::Blocks => Topic started by: Baz on May 22, 2006, 02:25:01 pm
Title: User template and output filename
Post by: Baz on May 22, 2006, 02:25:01 pm
Hello all, I want the output filename to be the name of the project. I'm using a custom template and have added
Code
<Option output="bin\Release\$(PROJECT_NAME).exe" /> in the template. Unfortunately, the $(PROJECT_NAME) variable picks up the name used in the template itself and not the name of the project. any ideas? Many thanks.
Title: Re: User template and output filename
Post by: Baz on May 22, 2006, 02:26:47 pm
Sorry about the bad layout in my post, but I can't edit it.
Title: Re: User template and output filename
Post by: fili on May 22, 2006, 03:58:06 pm
I think that this is a bug in the nightly builds. At home I'm using RC2 and $(PROJECT_NAME) works as intended. At work I'm using the 20-may build and $(PROJECT_NAME) gets replaced by the project name as it was when the template was saved.
Title: Re: User template and output filename
Post by: thomas on May 22, 2006, 04:32:41 pm
Title: Re: User template and output filename
Post by: Baz on May 22, 2006, 04:50:22 pm
@Thomas Clearly no problem at all for you, but for me, the name of the template is used as the .exe file name.
Let's say my template has "<Option title="Monkey/>" If I create a project from the user template (Monkey) and rename the project at the rename dialog to "Tiger", when I compile the project I get Monkey.exe and not Tiger.exe. Incidently, if the template title has a space in it like in your example, then I get a link error. For example, if my template is called Win32 Application, then when I complile the project I will get a link error along the lines of "Error loading Application.exe".
I know this isn't happening in your example, but it really is happening to me, honest, I'm not making it up.
Many thanks.
Title: Re: User template and output filename
Post by: fili on May 22, 2006, 05:11:27 pm
1. Create a new console app (using the wizard), modify it's output target, compile, test, save as a project template (mine is 1234). Works fine, outputs 1234.exe. 2. Create a new app (using the 1234 template), check it's output target, compile. 3. Altough the project name is hahaha 4. the compiled file is still 1234.exe instead of hahaha.exe That's the problem.
(I repeat, I'm using the nightly build. In RC2 works, as I can remember. I'll check when I get home)
[attachment deleted by admin]
Title: Re: User template and output filename
Post by: Baz on May 22, 2006, 05:39:32 pm
@fili That's exactly right.
I've just been experimenting with this and found something strange. I now have 2 .exe files. One with the template name and one with the project name. It seems that if you open Project -> build options, close it, and then re-compile, the proper named exe is created. Anyway, it looks like a bug to me and at least Thomas knows about it now.
Thanks all.
Title: Re: User template and output filename
Post by: sethjackson on May 22, 2006, 05:59:28 pm
Yeah I can confirm it. The problem is that when you save a project as a template, the output filename is hardcoded into the project file. So no matter if you change the project name the output filename is not getting updated..... I really don't have a good understanding of cbProject/how to fix this bug or I would try to fix it myself. If anyone wants to know the problem is in templatemanager.cpp NewProjectFromUserTemplate(). Well actually the best way would probably be to fix SaveUserTemplate() so that the output filename isn't hardcoded.
Title: Re: User template and output filename
Post by: fili on May 22, 2006, 08:10:30 pm
I don't think it's something hardcoded. It seems to be a memory leak, because if you restart C::B and create a new project using the same template, everything works. Therefore, I think that something remains in the memory after saving the template.