# Loading a library from a script

**URL:** <https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306>\
**Category:** ROOT\
**Created:** [April 3, 2017, 10:21pm UTC](https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306 "2017-04-03T22:21:03Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 4, 2017, 5:06pm UTC](https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306/5 "2017-04-04T17:06:37Z")

</div>

> [@Axel](#):
>
> R\_\_ADD\_LIBRARY\_PATH($FOODIR) // if needed  
> R\_\_LOAD\_LIBRARY(libFoo.dylib)

This worked nicely. The only downside was that the entire absolute path needed to be added. Does ROOT following environment variable for where to find headers and libraries? Something similar to gcc’s `INCLUDE_PATH`, `CPLUS_INCLUDE_PATH` and `LIBRARY_PATH`?

> [@Danilo](#):
>
> The first one, which is the one I recommend, is to use rootmpafiles. These allow ROOT to autoload the libraries needed for running the code and to parse the necessary headers. Creating a rootmapfile is very easy: just use the -rmf switch or --rootmap in rootcling or genreflex respectively.

I am generating the rootmap files as I am using the cmake macro `ROOT_GENERATE_LIBRARY` (which I have an issue with, but will not discuss here). I’m not sure how to use these files, it seems they need to be placed somewhere in particular? Remember I am trying to develop this for others to use so the idea is that a cmake file would properly place all the files in the correct places and the user would have to do very little to get it working.

Thanks for the responses so far, they are helpful.

---

_[View the full topic](https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306)._
