← Back to team overview

kicad-developers team mailing list archive

Re: Environment Variables

 

Hi Dick,

I made a simple manual but I forgot to send it. You can check it before I
send it to the mailing list since you might find something else to add or
to change:


*Using KiCad in Windows and Linux using the same Globa Libraries for
modules*


 To be able to use the same Global Libraries for modules we will need three
to do three things:

1) Have a path that can be accesed by both Windows and Linux ( A NTFS or
Fat32 Partition will do) to store the libraries.

2) Add the Environment Variable with the path where the libraries are in
each OS. (This step is not necesary but can be useful for people working
with Linux and OSX)

3) Create a lib-table with the path of each library using the Environmental
Variable and substitute the KiCad lib-table of each OS.


1) For the first step we will have to move all our libraries to a folder
inside of a drive that can be accessed by both systems, usually this is
done with a partition formatted in NTFS or Fat32 since Windows can't access
many of the files systems used in Linux. This can also be done with a USB
drive.

For my example, I will be using a partition formatted in NTFS. The path to
the folder with the libraries in each OS are the following :


Linux (The drive in my case is named : 6EF4F576F4F540BF ):
 /media/twistx77/6EF4F576F4F540BF/mylibs/

Windows: D:\mylibs\


2) Now that we have access to the libraries from both OS, we have to add
the necessary Environment Variables in each OS. The Environment Variable
will be used in this case to substitute a path that for a name, so if we
have different paths in each operative system, we can setup an evironment
variable that can have the same name in both OS but they point to the same
folder with the different path this folder can have en each OS.

We can use the Environment Variable determined by KiCad (KISYSMOD) or we
can just create our own. In this case, I will create a new variable called
KIMYLIBS to assign the paths of our libraries in each OS. In Linux there
are several ways to declare a Enviroment Variable which will depend on the
distribution, persistence of the variable and reach (user vs system). I
will be creating a session-wide environment in a Ubuntu based system.


To create the Environment Variable in Linux :

s*udo *gedit *~/.profile*

*In the files that have openned we have to add the following in the last
line:*

*export KIMYLIBS="/media/twistx77/6EF4F576F4F540BF/mylibs"*

*Then save **and close the file.*

*Now we reload the profile*

*source **~/.profile*

*Now, lets check if the variable is already set by using the command:*

*printenv **KIMYLIBS*

*We should see **/media/twistx77/6EF4F576F4F540BF/mylibs*


 To create the Environment Variable in Windows 7:

 1) Right click on the Computer icon on your Desktop or Start Menu and
choose Properties option.

  2) In the System window click on Advanced system settings in the left
pane.

  3) In the System Properties window select Advanced tab and click on
Environment Variables… button given at the bottom of the window.

  4) In the Environment Variables window you will notice two columns User
variables for a username and System variables.

  5) Now to add a new User variable click on New… button. In the New User
Variable dialog box type the KIMYLIB name and in Variable value add
D:\mylibsand click OK button

  6) Click OK button in the Environment Variables dialog window.

  7) Click OK on System Properties window.

 You might need to restart.


 For more information in how to setup Environment Variables check these
links:

https://help.ubuntu.com/community/EnvironmentVariables (Ubuntu)

http://www.nextofwindows.com/how-to-addedit-environment-variables-in-windows-7/


3) There are two ways of creating the lib-table. The first would be to open
PCBNew, go to Preferences>Library Tables and then add there the path
($KIMYLIB/resistors.pretty in Windows $KIMYLIB\resistors.pretty in Linux)
of each library with its name and plugin type Kicad.

Another way to do this is modify the lib-table file which can be located in
the home folder in Linux and at “C:\Users\<User
Name>\AppData\Roaming\kicad\” in Windows.

The file should contain something like this:


 (fp_lib_table

(lib (name resistors)(type KiCad)(uri $KIMYLIB/resistors.pretty)(options
"")(descr "Resistors"))

(lib (name capas)(type KiCad)(uri $KIMYLIB/caps.pretty)(options "")(descr
"Capacitors"))

)

where each line should have name of the library, type of library, path,
options, and description as in the Library Tables manager of PCBNew.

We have to pay atention in the path since in Linux we should have something
like this: $KIMYLIB/library.pretty while in Windows we should be using “\”
instead of “/” so it would be like this: $KIMYLIB\library.pretty


That's it.


2014-04-08 4:44 GMT+02:00 Dick Hollenbeck <dick@xxxxxxxxxxx>:

> On 03/17/2014 01:35 PM, Alejandro Méndez A. wrote:
> > Ok,
> >
> > I will do that in a new post with another title so it is easy to find.
>
> Alejandro
>
> Can you tell me if and where this has been done please?
>
> Thanks,
>
> Dick
>
>
>
> >
> > I could make a video since I already have a youtube channel with plenty
> of visits but I'm
> > not a native English speaker so I think it might be better just to keep
> the written version :)
> >
> > In fact I've been doing a tutorial for Kicad in Spanish but I haven't
> finished since the
> > last changes for KiCad have changed a lot in PCBNew and Library and I'm
> thinking of
> > redoing the first ones with a newer version of KiCad including the new
> features of PCBNew.
> > Should I keep waiting a little longer for more big changes?
> >
> > I'll try to make a useful post for the environment variables and how to
> use them to be
> > able to work with Kicad seamlessly in different platforms.
> >
> > Last but not least. I think there is already work being done with the
> libraries but I
> > think that it would be really good for KiCad to have a very large
> contributive components
> > library since most "hobbiest" users don't wan't to make their own parts
> and people like me
> > that are freelance or work for small companies will use already created
> components when
> > they come from a "respectable" source. I spend a lot of time creating my
> own footprints
> > and I've found that the best library out there in my opinion is this one:
> > http://smisioto.no-ip.org/elettronica/kicad/kicad-en.htm . Is anyone
> working on doing some
> > sort of collaborative library where people could create components and
> by users votes have
> > the components validate them-selves?
> > I know a little about the github "official" library for KiCad and also I
> know of a web
> > that is doing that for three differents packages (KiCad included), it is
> called
> > CircuitHub. It is a great idea but they try to cover too much, at least
> for now, in my
> > opinion. You can create the components in their web, et cetera. I've
> tried it and I've
> > even talked to one of the founders for support, since there are many
> things that don't
> > work right yet and they make it basically unusable at the end. They've
> told me they are
> > working on it, but it have passed at least 6 months and they have added
> other things but
> > the component creation part is still not working right. To the point of
> not even been able
> > to create new schematic symbols.
> >
> > Anyway, I just want to know if there is somebody working in an idea like
> that but just to
> > keep the components, not creating them in the web since I could help
> creating components
> > and a system to let people create components to share, following a
> common criteria which
> > could give some security to the people wanting to use them.
> >
> > BTW, sorry for the long boring reply.
> >
> >
> >
> >
> > 2014-03-17 18:57 GMT+01:00 Dick Hollenbeck <dick@xxxxxxxxxxx <mailto:
> dick@xxxxxxxxxxx>>:
> >
> >     On 03/17/2014 12:27 PM, Alejandro Méndez A. wrote:
> >     > Hi Dick,
> >     >
> >     > I already fixed it, I had a problem with the environment variable
> which in Linux you can
> >     > set it just for one user and I'm new to Linux.
> >     >
> >     > Now, if you can tell me where to write a little guide on how to do
> it, I will gladly do
> >     > it. If there is no such a place, I would just send it to the
> mailing list where someone
> >     > might find it.
> >
> >
> >     User's (yahoo) Mailing list is helpful!  TIA for that.
> >
> >     It would be good if you actually re-enforce the *concept* of what
> you are trying to do,
> >     not simply state how to set the environment variable.  The fact that
> it allowed you to
> >     achieve a single data file which is applicable across platforms,
> that is the concept.
> >
> >     It was in your original posting, but I would bring it into your
> summary posting.
> >
> >     Eventually, if somebody can make videos that help users, that will
> help users.  I suppose
> >     we can link to good videos from the website.
> >
> >     I think people struggle more with the concept of what the
> environment variable is doing,
> >     than they struggle with how to set it.  You at least saw this
> concept, and it puts you at
> >     the head of the class.
> >
> >     If you tell them only how to set it, next thing they'll ask is what
> variable do I set?
> >
> >     It would be best if you *invent* your own environment variable, and
> use that in your write
> >     up.  Like FPBASEDIR or something like that, anything meaningful.
>  And more than one is OK.
> >
> >     We actually use ${MY_LIBS} for our personal libraries, and put them
> on a network drive in
> >     pretty format, so that's where MY_LIBS points.
> >
> >     You can do the same with environment variables for the paths to the
> 3D models.
> >
> >
> >
> >     I will not be visiting the user's mailing list anymore, so your help
> is appreciated.
> >
> >
> >
> >
> >
> >
> > --
> >
> >
> > アレッカス
>
>


-- 


アレッカス

Follow ups

References