Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: vid512 on February 25, 2014, 09:50:26 pm

Title: Project->Build Options sets incorrect Build target
Post by: vid512 on February 25, 2014, 09:50:26 pm
When there are build targets, which do not include correct platform, they are not displayed in Build toolbar. But it seems that Project -> Build options takes index number of choice in Build toolbar, and uses it as index number of project target.

So for example if you have project with 4 build targets
1. linux-debug (Target Platform: Unix)
2. linux-release (Target Platform: Unix)
3. win-debug (Target Platform: Windows)
4. win-release (Target Platform: Windows)

You open this project from Windows C::B. Your Build toolbar lists two targets:
1. win-debug
2. win-release

If you choose the second (win-release) option in Build toolbar, and go to Project -> Build options, it will act as if you had the second build target (linux-release) active.

Project->Build options is probably not the only place this bug manifests. For example if you don't have GCC compiler set in Windows C::B, it constantly keeps nagging you that you should set up GCC compiler ("Can't find compiler executable in your configured GCC search path..."), even though no project targeted for current platform uses GCC.
Title: Re: Project->Build Options sets incorrect Build target
Post by: oBFusCATed on February 26, 2014, 12:38:00 am
What C::B version is exhibiting this bug? 13.12, 12.11, nightly?
Title: Re: Project->Build Options sets incorrect Build target
Post by: vid512 on February 26, 2014, 10:41:29 am
nightly, svn rev 9660
Title: Re: Project->Build Options sets incorrect Build target
Post by: vid512 on February 26, 2014, 11:29:46 am
This seems to affect debugging as well. When I try to debug windows target, C::B stays in some kind of "starting debugger" phase (lots of things disabled) indefinitely. If I enable C::B debugging (codeblocks -d), I can see following in CodeBlock Debug log window:

Quote
Can't find compiler executable in your configured search path's (for GNU GCC Compiler)...
Can't find compiler executable in your configured search path's (for GNU GCC Compiler)...
Title: Re: Project->Build Options sets incorrect Build target
Post by: oBFusCATed on February 26, 2014, 09:29:28 pm
Can you provide one sample project which can be used to reproduce the problem?
Title: Re: Project->Build Options sets incorrect Build target
Post by: vid512 on February 26, 2014, 10:06:01 pm
Just tested and got the bug (both wrong Build Options and hanged debugging) on following project. Sorry, the project is a bit hacked together from what I got from the projecty wizard, but it exhibits the bug.

tempproj.cbp:
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="tempproj" />
<Option pch_mode="2" />
<Option compiler="msvc10" />
<Build>
<Target title="lin-dbg">
<Option platforms="Unix;" />
<Option output="bin/Debug/tempproj" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="/Zi" />
<Add option="/D_DEBUG" />
<Add option="/MDd" />
</Compiler>
<Linker>
<Add option="/DEBUG" />
<Add library="msvcrtd.lib" />
<Add library="msvcprtd.lib" />
</Linker>
</Target>
<Target title="lin-rel">
<Option platforms="Unix;" />
<Option output="bin/Release/tempproj" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="/Ox" />
<Add option="/DNDEBUG" />
<Add option="/MD" />
</Compiler>
<Linker>
<Add library="msvcrt.lib" />
<Add library="msvcprt.lib" />
</Linker>
</Target>
<Target title="win-dbg">
<Option output="tempproj" prefix_auto="1" extension_auto="1" />
<Option type="1" />
<Option compiler="msvc10" />
<Option use_console_runner="0" />
</Target>
<Target title="win-rel">
<Option platforms="Windows;" />
<Option output="tempproj" prefix_auto="1" extension_auto="1" />
<Option type="1" />
<Option compiler="msvc10" />
<Option use_console_runner="0" />
</Target>
</Build>
<Compiler>
<Add option="/W3" />
<Add option="/EHsc" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

main.cpp
Code
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
Title: Re: Project->Build Options sets incorrect Build target
Post by: White-Tiger on February 26, 2014, 11:44:07 pm
even though it's not directly related to your problem... I still want to comment on this "Target Platform" stuff :P
I prefer to either set "Target Platform" always to "All" or use different project files per target...

Reason is that selecting a platform kills usability. I cannot edit other platform targets (such as increasing or lowering the optimization limit globally, or static linking, libs etc.)
Nor can I use it for cross compilation... as when I want to cross compile for GNU/Linux, I have to set the target to "Windows" as I'm otherwise unable to use my cross compiler on Windows... (and this splits the project file, as my GNU/Linux target can either compile on Windows or GNU/Linux, but not on both, without setting it to "All" even though it's actually meant to be for GNU/Linux)

Code::Blocks would be perfect if it had a way to custom some project stuff without actually changing the project file :P That might improve Subversion use a bit... (eg. interpret used compiler different per project basis without actually changing it within the project file)
Title: Re: Project->Build Options sets incorrect Build target
Post by: vid512 on February 26, 2014, 11:46:56 pm
I agree there are cases when that feature is of no use. But in simple cases like mine (build windows version on windows, build linux version on linux) it is a good thing to have.