歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

linux中設置環境變量和gcc/g++的include路徑

1、設置linux默認的環境變量

1.1 查看當前默認的環境變量:

echo PATH

結果:

root@hyman-laptop:/home/hyman/src# echoPATH

結果:

root@hyman-laptop:/home/hyman/src# echo PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/snap/bin

1.2 在環境變量裡增加新的路徑 /home/mlm

在/etc/profile 文件中最後面增加下面這句話:

export PATH=$PATH:/home/mlm

1.3 保存後在終端中輸入下面的語句,以重啟配置:

source /etc/profile

1.4 再次查詢,發現已經成功:

root@hyman-laptop:/home/hyman/src# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/snap/bin:/home/mlm

2、設置gcc默認的inlcude路徑(在終端或在/etc/profile輸入):

C_INCLUDE_PATH=/new/include/dir

export C_INCLUDE_PATH

3、設置g++默認的include路徑(在終端或在/etc/profile輸入):

CPLUS_INCLUDE_PATH=/new/include/dir

export CPLUS_INCLUDE_PATH

Copyright © Linux教程網 All Rights Reserved