Author Topic: Project->Build Options sets incorrect Build target  (Read 12700 times)

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Project->Build Options sets incorrect Build target
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Project->Build Options sets incorrect Build target
« Reply #1 on: February 26, 2014, 12:38:00 am »
What C::B version is exhibiting this bug? 13.12, 12.11, nightly?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Project->Build Options sets incorrect Build target
« Reply #2 on: February 26, 2014, 10:41:29 am »
nightly, svn rev 9660

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Project->Build Options sets incorrect Build target
« Reply #3 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)...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Project->Build Options sets incorrect Build target
« Reply #4 on: February 26, 2014, 09:29:28 pm »
Can you provide one sample project which can be used to reproduce the problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Project->Build Options sets incorrect Build target
« Reply #5 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;
}

Offline White-Tiger

  • Multiple posting newcomer
  • *
  • Posts: 83
Re: Project->Build Options sets incorrect Build target
« Reply #6 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)
« Last Edit: February 26, 2014, 11:48:44 pm by White-Tiger »
Windoze 8.1 x86_64 16GiB RAM, wxWidgets-2.8x (latest,trunk), MinGW-builds (latest, posix-threads)
Code::Blocks (x86 , latest , selection length patch , build option fixes/additions , toggle comments)

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Project->Build Options sets incorrect Build target
« Reply #7 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.