如何将环境变量传递给 Ubuntu 上的 Netbeans Makefile? [英] How do I pass an environment variable to a Netbeans Makefile on Ubuntu?
问题描述
我在 Linux (Ubuntu 9.04) 上使用 Netbeans 来构建 C 项目.
I'm using Netbeans on Linux (Ubuntu 9.04) to build a C project.
如何传入环境变量以使其对 Makefile 可见?
How do I pass in an environment variable so that's it's visible to the Makefile?
如果我执行正常的export MYVAR="xyz"
,然后从命令行运行make
,这当然可以正常工作.
If I do a normal export MYVAR="xyz"
and then run make
from the command line this works fine of course.
但 Netbeans 似乎不使用 .bashrc
环境,所以如果我在 Netbeans 中单击构建",则生成失败.
But Netbeans doesn't seems to use the .bashrc
environment, so if I click "build" in Netbeans, the make fails.
有趣的是,MacOSX 上似乎没有出现此问题 - 我已将变量添加到 ~/.MacOSX/environment.plist
,并且该值 是对 Netbeans 可见.
Interestingly, the problem doesn't seem to occur on MacOSX - I've added the variable to ~/.MacOSX/environment.plist
, and that value is visible to Netbeans.
我发现这篇文章 建议修改~/netbeans-6.8/etc/netbeans.conf
.我已经尝试过,通过将 -J-DMYVAR=xyz
添加到 netbeans_default_options
的末尾,即:
I found this post which suggested modifying ~/netbeans-6.8/etc/netbeans.conf
. I've tried this, by adding -J-DMYVAR=xyz
to the end of netbeans_default_options
, ie:
netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-DMYVAR=xyz"
但这似乎不起作用.
推荐答案
此答案可能不适用于基于 Unity 的 Ubuntu.
This answer is possibly not valid for Unity-based flavours of Ubuntu.
该问题实际上与 NetBeans 无关 - 它与 Ubuntu(即 Gnome)启动器有关.
The issue is actually nothing to do with NetBeans - it's related to the Ubuntu (ie Gnome) Launcher.
正如这篇博文所述,您需要将变量添加到相当晦涩的 ~/.gnomerc
(No Mercy?:) 文件中,以便将它们传递给使用 Launcher 启动的应用程序!
As this blog post explains, you need to add variables to the rather obscure ~/.gnomerc
(No Mercy? :) file in order for them to be passed to applications started with Launcher!
所以只需编辑 ~/.gnomerc
并像在 ~/.bashrc
中一样添加变量,例如:
So just edit ~/.gnomerc
and add the variables as you would to ~/.bashrc
, eg:
export MYVAR="xyz"
然后注销/登录.
这篇关于如何将环境变量传递给 Ubuntu 上的 Netbeans Makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!