Use environment variables in eclipse

I have a CDT eclipse project using the Cross GCC toolchain. The cross compiler path must be set in the tool binding settings: C / C ++ Build -> Settings -> Cross Settings -> Path.

Because of sharing this project with other people, the path to the cross compiler must be in an environment variable that I named LINUX_DEVKIT_PATH.

I have defined LINUX_DEVKIT_PATH as environment variable and used "$ LINUX_DEVKIT_PATH / bin" in C / C ++ Build -> Settings -> Cross Settings -> Path. But with these settings no compiler was found. I also tried using C / C ++ Build -> Environment -> Select ... to add the variable to the list. The environment variable was found and appears in the source list. User: Config.


source to share

3 answers

In your Eclipse, you can set environment variables and values ​​to be used when the application starts.

To set environment variables:

  • In the C / C ++ Projects View, select a project.
  • Click Run> Run or Run> Debug.
  • In the Configurations window, expand the C / C ++ Local node.
  • Select a run or debug configuration.
  • Click on the "Environment" tab.
  • Perform one of the following actions:
    • To create a new environment variable, click New.
    • To import an environment variable, click Import.
    • To modify an existing environment variable, select an item from the list and click Modify.
    • To remove an existing environment variable, select an item from the list and click Remove.
  • Enter a name in the Name field.
  • Enter a value in the Value field.
  • Click Run or do the following:

To specify the execution arguments that the application uses and to specify the working directory for the launch configuration, see Defining Execution Arguments. To select a debugger to use when debugging an application, see Section Selecting a debugger. To specify the location of source files used when debugging a C or C ++ application, see Section Locating source files. To specify where startup configuration is stored, how to access it and the perspective of opening when the application starts, see the "Locate the startup configuration" section.

Good luck to my friend. And if this post answers your question, be sure to accept it as the answer.



What worked for me:

  • I created an environment variable MY_CROSS_BIN

    with my content "Path". Cross settings.
  • "Selected" to the project (project -> properties -> C / C ++ Build -> Environment)
  • I edited the PATH variable in the same properties window to point to: ${MY_CROSS_BIN}${PathDelimiter}${PATH}

  • I cleared (left blank) Path Parameters in C / C ++ Build -> Settings

seems to work ... but it mangles Eclipse's auto-detection (including not found anymore, etc.)



It seems that Eclipse keeps getting better, and yet ... All Eclipse problem answers will appear in the form "it worked for me".

This worked for me:

Create a project:   
File-> New -> Makefile Project With Existing Code
+ Browse to existing code location
+ Toolchain: Cross ARM GCC


There is your new project. Fine

Try to build. The All command appears on the console. (Hopefully your program in your path is "all" not rm -f ~ /)

NOW Open the project properties and click though all C / C ++ build options. Don't change them, just click on them. Click OK to exit.

Now try to build again: Voila! it works:

make everything done.

(Eclipse is disappointing.)



All Articles