c++netbeansmakefile

NetBeans C/C++ plugin: How to adjust the environment for make?


How does the NetBeans C/C++ plugin create an environment for make in Linux? In Windows? How can I modify this environment according to my needs?

I've created a "Project With Existing Sources" (in NetBeans 8.0.2). The project has 4-line Makefile (below) and nothing else.

SHELL = /bin/bash
MYENV = $(shell env | sort)

all:
        @echo $(MYENV)

When I run this makefile I get a list of environment variables with their values (I'm not posting this list, because anybody can get it easily). All my attempts to use NetBeans controls to change the environment didn't lead me anywhere - the environment remains unchanged.


Solution

  • This my question got stuck in time... I'm answering it now, after ten years, using the NetBeans 23, which is not that different from the NetBeans 8.0.2 I worked with before. The answer is simple:

    You can interactively (using the IDE) add any variables together with their values into the make environment if and only if your C/C++ project is "managed" by the NetBeans.

    If your project is managed by NetBeans (i.e. this IDE creates your Makefile) you can open the Options dialog and find the field Make Options. As you can see below I've added two variables ABC=abc DEF=def there:

    Options-Dialog

    Then, when you build (in the IDE) you'll see the following line (among others):

    /usr/bin/gmake ABC=abc DEF=def -f Makefile CONF=Debug
    

    BTW, if you build from the command line (outside the IDE) you won't see these additional make options from the NetBeans Options dialog.

    All this doesn't work if your C/C++ project is not managed by NetBeans - for example, if it's a "Project With Existing Sources". This is the type of projects I prefer to work with (for many reasons), and that's why I had this question. Bug or feature? No idea...