Author Topic: How to turn off implicit -I- GCC compiler switch?  (Read 5655 times)

Offline uentity

  • Single posting newcomer
  • *
  • Posts: 3
How to turn off implicit -I- GCC compiler switch?
« on: February 22, 2008, 03:34:57 pm »
Hi!
I've just discovered Code::Blocks and it's an amazing IDE!
But I can't solve one annoying problem - when using C::B under Linux with GCC as default compiler an implicit switch -I- is substituted just before other include directives. My GCC 4.2.2 complains about it:
"obsolete option -I- used, please use -iquote instead"
More than that, I've found that this switch leads to compilation errors and prevents my sources from building normally. I've checked all the property pages several times but failed to locate the magic option that controls the addition of this switch.
Do someone has any ideas?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to turn off implicit -I- GCC compiler switch?
« Reply #1 on: February 22, 2008, 04:03:12 pm »
IIRC, this is controlled by the PCH options in project properties. Try playing with those options.
Be patient!
This bug will be fixed soon...

Offline uentity

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to turn off implicit -I- GCC compiler switch?
« Reply #2 on: February 22, 2008, 07:44:41 pm »
Thanks, that was helpful!
Setting the precompiled headers to be generated in the object dir involves adding -I- compiler switch for GCC. I suppose that PCH-related option makes sense only in conjunction with MSVS compiler, am I right? If so, should this behavior be considered as a bug?
This question leads to more generic one - can I use the same project file in Windows (MS compiler) and Linux (GCC compiler) having defined several targets only for Windows MS compiler (and don't touch them in Linux) and similarly some Linux GCC build targets? Is it the right way to go? Or there can be some "non-portable" project options that can produce implicit building problems when switching the platform? Or should I create separate project files for every compiler I use?
Is there some kind of "official" answer for this question?
PS. Something tells me that I should RTFM first, but I'll be grateful to you for response.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to turn off implicit -I- GCC compiler switch?
« Reply #3 on: February 22, 2008, 09:29:10 pm »
Setting the precompiled headers to be generated in the object dir involves adding -I- compiler switch for GCC. I suppose that PCH-related option makes sense only in conjunction with MSVS compiler, am I right? If so, should this behavior be considered as a bug?

No, as a matter of fact, PCH support was first added for GCC (in C::B that is).


This question leads to more generic one - can I use the same project file in Windows (MS compiler) and Linux (GCC compiler) having defined several targets only for Windows MS compiler (and don't touch them in Linux) and similarly some Linux GCC build targets? Is it the right way to go? Or there can be some "non-portable" project options that can produce implicit building problems when switching the platform? Or should I create separate project files for every compiler I use?
Is there some kind of "official" answer for this question?
PS. Something tells me that I should RTFM first, but I'll be grateful to you for response.

Each target, as well as the project as a whole, has a "platforms" setting which you can use to explicitely mark a project or target as being valid only under certain platforms.
Once again, inspect the project properties window closely.
Be patient!
This bug will be fixed soon...

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: How to turn off implicit -I- GCC compiler switch?
« Reply #4 on: February 23, 2008, 12:15:54 am »
Each target, as well as the project as a whole, has a "platforms" setting which you can use to explicitely mark a project or target as being valid only under certain platforms.
Once again, inspect the project properties window closely.

That is interesting. I have a project using MSVC on Windows and GCC on Linux. It works using 2 build targets for Win and 2 for Linux. However, on linux I always get an annoying warning that "The defined compiler for W32_Debug cannot be located (ID: msvc8), please choose the compiler you want to choose and click OK", see attachment for actual dialog. The problem is that it should not ask about this build target at all on Linux, "Cancel" is the only way out, but it has to be done for every project in the workspace, every time the workspace is opened.

I tried setting the Build target options/Platforms to be "Windows" only for this target and "Unix" for the Linux targets, but the behaviour is no different, I still get the same question at startup. Is there a way to fix it?

[attachment deleted by admin]

Offline uentity

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to turn off implicit -I- GCC compiler switch?
« Reply #5 on: February 24, 2008, 10:13:54 am »
Each target, as well as the project as a whole, has a "platforms" setting which you can use to explicitely mark a project or target as being valid only under certain platforms.
Once again, inspect the project properties window closely.

Thanks for clarification, now I see why these options were introduced.
Build works fine, now I'm trying to find out how to correctly setup LD_LIBRARY_PATH inside Code::Blocks _before_ launching the debugger;) Maybe someone has a quick answer?