Author Topic: Setting enviroment variable for cross compiling  (Read 7953 times)

Offline CmKaHo

  • Multiple posting newcomer
  • *
  • Posts: 26
Setting enviroment variable for cross compiling
« on: April 20, 2007, 12:54:39 pm »
Hi,
is it possible to set enviroment variable (aka. bash export CROSS_COMPILE=ppc_6xx-) for specific compiler or project? Problem: when cross compiling under linux/i386, CROSS_COMPILE variable have to be set for a gcc cross compiler.
I temporary solved it by setting variable for whole c::b session, but this is not an elegant solution.

Thanx, Karel.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Setting enviroment variable for cross compiling
« Reply #1 on: April 20, 2007, 12:58:26 pm »
Use Environments Plugin.

Go through Settings > Environments > Environment variables and define the Environment variables you want.
Be a part of the solution, not a part of the problem.

Offline CmKaHo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Setting enviroment variable for cross compiling
« Reply #2 on: April 20, 2007, 01:11:38 pm »
Thx, it works.
But. Problem remains same. It is a global setting - for whole c::b. I need variable only for specific compiler (Setting->Compiler and degugger...) or project. This variable has to be set only when I am compiling project via. cross compiler. Not when I compile native project. Or, worse, if I have two cross platforms, I will need to switch those variable between compiling.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Setting enviroment variable for cross compiling
« Reply #3 on: April 20, 2007, 09:33:38 pm »
how about Project->Build Options->Custom Variables?
or Settings -> Compiler and Debugger -> Global Compiler Settings -> Custom Variables

Offline CmKaHo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Setting enviroment variable for cross compiling
« Reply #4 on: April 23, 2007, 08:35:33 am »
This could not work. Custom Variables did not impact compile environment. They serves as variables which could be use in time of compilation.

Offline CmKaHo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Setting enviroment variable for cross compiling
« Reply #5 on: April 24, 2007, 09:31:28 pm »
Yes. It is really required to set environment variable for cross compiling (at least in my case). Solution mentioned by Biplab works fine (i used bash export before).
The problem is, that I am developping cross application (PPC) and native application (x86) in one time. So I have to manually switch on and off this variable - works, but uncomfortable.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting enviroment variable for cross compiling
« Reply #6 on: April 25, 2007, 12:12:30 am »
Post a feature request for the env.vars plugin. It shouldn't be difficult to add per-project/target env. variables.
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Setting enviroment variable for cross compiling
« Reply #7 on: April 25, 2007, 08:11:05 am »
Post a feature request for the env.vars plugin. It shouldn't be difficult to add per-project/target env. variables.
Well this would only make sense if the envvars are stored in the project file... is that what you mean?

I had the idea to provide the envvars plugin with the possibility to store different sets of envvars (not only one). The sets can than be selected (similar to the global variables) but are project-independent. I would have found that useful some month ago but didn't get it ready (so far)...

Anyways: IIRC there was a time where the custom variables were *also* exported to envvars if setup. Should this feature return? (I know it's difficult in case it overwrites a real "global" system variable but this would be the same for the plugin anyway...)

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting enviroment variable for cross compiling
« Reply #8 on: April 25, 2007, 08:49:43 am »
Quote
Well this would only make sense if the envvars are stored in the project file... is that what you mean?

Yes.

Quote
Anyways: IIRC there was a time where the custom variables were *also* exported to envvars if setup. Should this feature return?

That's a possibility too :).
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Setting enviroment variable for cross compiling
« Reply #9 on: April 25, 2007, 10:28:37 am »
That's a possibility too :).
Looking into it... it seems to be as simple as to modify compileroptionsbase.cpp "SetVar", "UnsetVar" and "UnsetAllVars" accordingly... Should it really be as simple as that?!
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline CmKaHo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Setting enviroment variable for cross compiling
« Reply #10 on: April 25, 2007, 12:56:28 pm »
Feature req. 003350 established.
Well this would only make sense if the envvars are stored in the project file... is that what you mean?

Yes - this is one (good) way.

Quote
Anyways: IIRC there was a time where the custom variables were *also* exported to envvars if setup. Should this feature return?
That's a possibility too :).

Good idea. Simple and sufficient.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting enviroment variable for cross compiling
« Reply #11 on: April 25, 2007, 12:59:10 pm »
That's a possibility too :).
Looking into it... it seems to be as simple as to modify compileroptionsbase.cpp "SetVar", "UnsetVar" and "UnsetAllVars" accordingly... Should it really be as simple as that?!
With regards, Morten.

No :)
These just set/unset the variables in the respective target/project.

Search in macrosmanager.cpp for calls to GetAllVars(). That's where it accesses the custom variables of a project/target/compiler and it's where we 'd export them to the environment if we needed to (although now it would be an all-or-nothing deal).
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Setting enviroment variable for cross compiling
« Reply #12 on: April 25, 2007, 07:03:58 pm »
(although now it would be an all-or-nothing deal).

too hard to have a checkbox option on each custom variable?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting enviroment variable for cross compiling
« Reply #13 on: April 25, 2007, 10:02:18 pm »
(although now it would be an all-or-nothing deal).

too hard to have a checkbox option on each custom variable?

Yes because we 'd have to change the base type that stores these custom variables.
And changing the sdk interface at this time is out of the question...
Be patient!
This bug will be fixed soon...