# Problem loading Garfield libraries in MacOs

**URL:** <https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208>\
**Category:** Garfield++\
**Created:** [January 22, 2023, 8:41am UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208 "2023-01-22T08:41:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Galan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/javier_galan/32/29662_2.png) [@Javier\_Galan](https://root-forum.cern.ch/u/Javier_Galan)\
**Post date:** [January 22, 2023, 8:41am UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/1 "2023-01-22T08:41:34Z")

</div>

I am running into problems while trying to load Garfield libraries into ROOT.

Just after the Garfield compilation succeeds, I load the Garfield setup.sh and try using `gSystem->Load("libGarfield.dylib")`.

I get the following error:

```auto
- Installing: /Users/jgalan/apps/garfield6/share/Garfield/cmake/GarfieldTargets.cmake
-- Installing: /Users/jgalan/apps/garfield6/share/Garfield/cmake/GarfieldTargets-release.cmake
-- Installing: /Users/jgalan/apps/garfield6/share/Garfield/cmake/GarfieldConfig.cmake
-- Installing: /Users/jgalan/apps/garfield6/share/Garfield/cmake/GarfieldConfigVersion.cmake
-- Installing: /Users/jgalan/apps/garfield6/share/Garfield/setupGarfield.sh
-- Installing: /Users/jgalan/apps/garfield6/share/Garfield/setupGarfield.csh

Javiers-MBP:installation jgalan$ source /Users/jgalan/apps/garfield6/share/Garfield/setupGarfield.sh
Javiers-MBP:installation jgalan$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.26/10 https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Nov 16 2022, 10:42:54 |
  | From tags/v6-26-10@v6-26-10 |
  | With Apple clang version 14.0.0 (clang-1400.0.29.202) |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] gSystem->Load("libGarfield.dylib");
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Users/jgalan/apps/garfield6/lib/libGarfield.0.3.0.dylib, 0x0009): Library not loaded: @rpath/libmagboltz.11.dylib
  Referenced from: <F5C2FAE8-2631-3195-A61B-31EA277A7369> /Users/jgalan/apps/garfield6/lib/libGarfield.0.3.0.dylib
  Reason: tried: '/Users/jgalan/rest-framework/install/lib/libmagboltz.11.dylib' (no such file), '/Users/jgalan/apps/root-6.26.10/install/lib/libmagboltz.11.dylib' (no such file), '=/Users/jgalan/rest-framework/install/lib/libmagboltz.11.dylib' (no such file), '/Users/jgalan/apps/root-6.26.10/install/lib/../lib/libmagboltz.11.dylib' (no such file), '/Users/jgalan/apps/root-6.26.10/install/bin/../lib/libmagboltz.11.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libmagboltz.11.dylib' (no such file), '/Users/jgalan/apps/root-6.26.10/install/lib/../lib/libmagboltz.11.dylib' (no such file), '/Users/jgalan/apps/root-6.26.10/install/bin/../lib/libmagboltz.11.dylib' (no such file), '/usr/local/lib/libmagboltz.11.dylib' (no such file), '/usr/lib/libmagboltz.11.dylib' (no such file, not in dyld cache)
root [1] 

```

I would expect that setupGarfield.sh would load all the necessary paths.

It seems it tries to find `libmagboltz.11.dylib`. The file is found inside `/Users/jgalan/apps/garfield6/lib`, same place as `libGarfield.dylib`. So why it does not find it? Perhaps in MacOs `magboltz` needs to be added to the compilation targets somewhere.

Any help welcome!  
Thanks!

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [January 22, 2023, 9:17pm UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/2 "2023-01-22T21:17:47Z")

</div>

Hi @Javier_Galan,

It seems it’s trying to locate the library using only the `@rpath` (run path) of the binary -in this case the ROOT binary-.  
Perhaps you could try manually adding the directory you mention as part of the library search path list, as in

```bash
$ export DYLD_LIBRARY_PATH=/Users/jgalan/apps/garfield6/lib:$DYLD_LIBRARY_PATH
$ root
root [0] gSystem->Load("libGarfield.dylib"); // or alternatively, write
                                             // the full path here
...

```

> [@Javier\_Galan](#):
>
> I would expect that setupGarfield.sh would load all the necessary paths.

For this, maybe @hschindl knows better.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![Javier\_Galan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/javier_galan/32/29662_2.png) [@Javier\_Galan](https://root-forum.cern.ch/u/Javier_Galan)\
**Post date:** [January 22, 2023, 10:56pm UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/3 "2023-01-22T22:56:17Z")

</div>

I get a different error now. Perhaps is not properly finding the `pcm` file?

```auto
root [0] gSystem->Load("libGarfield.dylib");
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for Medium.hh
   requested to autoload type Garfield::Medium
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for Solid.hh
   requested to autoload type Garfield::Solid
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for Geometry.hh
   requested to autoload type Garfield::Geometry
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for Component.hh
   requested to autoload type Garfield::Component
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for Sensor.hh
   requested to autoload type Garfield::Sensor
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for ViewDrift.hh
   requested to autoload type Garfield::ViewDrift
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for AvalancheMicroscopic.hh
   requested to autoload type Garfield::AvalancheMicroscopic
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for ComponentGrid.hh
   requested to autoload type Garfield::ComponentGrid
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for ComponentFieldMap.hh
   requested to autoload type Garfield::ComponentFieldMap

```

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [January 22, 2023, 11:05pm UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/4 "2023-01-22T23:05:38Z")

</div>

To me it seems like some path is missing in the include path list, but @hschindl perhaps knows or has seen this before.

Out of curiosity, did you source the `setupGarfield.sh` file in your current shell?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [January 23, 2023, 6:55am UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/5 "2023-01-23T06:55:36Z")

</div>

Can you try loading `libmagboltz` before `libGarfield`?

```auto
gSystem->Load("libmagboltz.dylib");
gSystem->Load("libGarfield.dylib");

```

---

<div class="post-metadata">

**Author:** ![Javier\_Galan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/javier_galan/32/29662_2.png) [@Javier\_Galan](https://root-forum.cern.ch/u/Javier_Galan)\
**Post date:** [January 23, 2023, 8:27am UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/6 "2023-01-23T08:27:17Z")

</div>

Perhaps the dictionaries haven’t been generated, or they were not included inside the target?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [January 24, 2023, 12:41pm UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/7 "2023-01-24T12:41:58Z")

</div>

Hm, strange… it works on my MacBook (macOS 12.6, ROOT 6.26/02). What OS and ROOT version are you using?

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 7, 2023, 12:42pm UTC](https://root-forum.cern.ch/t/problem-loading-garfield-libraries-in-macos/53208/8 "2023-02-07T12:42:12Z")

</div>

Closed on February 7, 2023, 12:42pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
