Can't permanently change path
I have tried a few things I found searching the net, but it's not working...
I would like to add a directory (from my home directory) to PATH, so the compiler can find my personal libraries. This is what I've done so far: $ PATH = $PATH:/home/programs/[name of library] $ export PATH $ echo $PATH returns :/home/programs/[name of library] But it doesn't stay this way! When I exit and then open a new shell terminal, echo $PATH returns my "old" PATH without the addition. I read something about changing the bashrc file, but I opened it, and I don't understand what kind of changes I could do... Thanx! |
put it in your rc file -- with bash, use ~/.bashrc
|
Thanx! That was fast!
Still confused... This is what my ~/.bashrc file looks like: # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # enable programmable completion features if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi Where do I put the /home/programs/{name} part? |
Add a line like you did on console:
Code:
export PATH=$PATH:/home/programs/lib But now a noob question back: aren't libraries better added to the system by a tool like ldconfig? I thought this method is usually used for calling commands... |
I did that, but it doesn't "stick".
As soon as I close the shell terminal, I'm back to the old PATH. I don't know anything about Idconfig. Can you use that for "home made" libraries? By the way: We should be telling "Norwegian and Swede" - jokes, since I'm Norwegian (even though I'm located in the US)... Juust kidding. |
what exactly is the directory structure? (like /home/programs/????? ( are there only libs in here or executables to?)).
as far as ldconfig, define "home made" libs (are they shared libraries, static, objects, etc..). |
I'll give an example, so I'm sure I give enough info:
One Directory is Printer. It is in ~/programs which I created for this purpose. Printer has two directories: /include and /lib. /include has one file named Printer.h, and /lib has one file named Printer.cpp. These are from my C++ instructor, and are supposed to be used in a program to print to file. Sorry I'm so vague, I've just been doing this for a couple of weeks... Thank you |
well, if you add at the bottom of ~/.bashrc the export line above that should work. after you compile Printer.cpp try typing the name of the executable(Printer) and see if it works.
|
OK Just making sure
My .bashrc should look like this after I'm done? # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # enable programmable completion features if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi export PATH = $PATH:/home/programs/Printer If I need to add on more, can I just add another line? I REALLY appreciate your help! |
Code:
# .bashrc Code:
# .bashrc Code:
# .bashrc .bashrc is a BASH script that gets run when you login. There is also .logout (I think) or was it .bash_logout if you want Linux do something like clean up before logging out. |
Thank you!
This is exactly what I've been trying to find. |
You can also put the export PATH = ..... line in the file ~/.bash_profile
.bash_profile is read when you invoke a login shell, .bashrc is read when you invoke a non login shell. I am not 100% sure what an xterm is invoked as. --Ian |
All times are GMT -5. The time now is 07:46 AM. |