Installation error at make step

Hello,

I am trying to install Garfield++ using the instructions from this webpage: Installation - Garfield++

At the “make -j4” step, I encountered the following error

In file included from input_line_9:7:
In file included from /home/d/Nuclear_phys4bash/Garfield/Include/Garfield/ComponentFieldMap.hh:10:
In file included from /home/d/Nuclear_phys4bash/Garfield/Include/Garfield/Component.hh:9:
/home/d/Nuclear_phys4bash/Garfield/Include/Garfield/Symmetry.hh:144:7: error: cannot initialize a variable of type 'const Garfield::Symmetry::Type' with an rvalue of type 'unsigned int'
      static_cast<std::uint32_t>(Type::PeriodicX) |
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/d/Nuclear_phys4bash/Garfield/Include/Garfield/Symmetry.hh:152:7: error: cannot initialize a variable of type 'const Garfield::Symmetry::Type' with an rvalue of type 'unsigned int'
      static_cast<std::uint32_t>(Type::PeriodicY) |
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/d/Nuclear_phys4bash/Garfield/Include/Garfield/Symmetry.hh:160:7: error: cannot initialize a variable of type 'const Garfield::Symmetry::Type' with an rvalue of type 'unsigned int'
      static_cast<std::uint32_t>(Type::PeriodicZ) |
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am not sure what is wrong. Before this step, I did “cmake $GARFIELD_HOME”, and it ran successfully. I only got the following warning that it couldn’t find Geant4:

CMake Warning at Examples/Geant4GarfieldInterface/CMakeLists.txt:16 (find_package):
  By not providing "FindGeant4.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Geant4", but
  CMake did not find one.

  Could not find a package configuration file provided by "Geant4" with any
  of the following names:

    Geant4Config.cmake
    geant4-config.cmake

  Add the installation prefix of "Geant4" to CMAKE_PREFIX_PATH or set
  "Geant4_DIR" to a directory containing one of the above files.  If "Geant4"
  provides a separate development package or SDK, be sure it has been
  installed.

Please note that I haven’t installed Geant4. Also, the installation page has no mention regarding Geant4.

Any suggestions on how to solve this error? I have no prior knowledge to Garfield, so, sorry in advance if this question is too naive. My ROOT and OS versions are

OS: Ubuntu 20.04.6 LTS x86_64
ROOT: 6.24/08 (Built for linuxx8664gcc)

Best,
Divyang.

Perhaps @hschindl can help with this.

Hi,
can you do a git pull and try again? This fix by Francois Lagarde (thanks a lot!) should solve the issue:

Thanks!

This update solved the errors I mentioned in the question. However, I got the following error during the “make -j4” step:

[ 43%] Linking CXX executable plot_gas
[ 43%] Linking CXX executable mwpc
[ 44%] Linking CXX executable ion_signal
[ 44%] Linking CXX executable full_tpc_sim
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/plot_gas.dir/build.make:108: Examples/AliceTPC/plot_gas] Error 1
make[1]: *** [CMakeFiles/Makefile2:2117: Examples/AliceTPC/CMakeFiles/plot_gas.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AnalyticField/CMakeFiles/mwpc.dir/build.make:108: Examples/AnalyticField/mwpc] Error 1
make[1]: *** [CMakeFiles/Makefile2:2213: Examples/AnalyticField/CMakeFiles/mwpc.dir/all] Error 2
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/ion_signal.dir/build.make:108: Examples/AliceTPC/ion_signal] Error 1
make[1]: *** [CMakeFiles/Makefile2:2149: Examples/AliceTPC/CMakeFiles/ion_signal.dir/all] Error 2
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/full_tpc_sim.dir/build.make:108: Examples/AliceTPC/full_tpc_sim] Error 1
make[1]: *** [CMakeFiles/Makefile2:2181: Examples/AliceTPC/CMakeFiles/full_tpc_sim.dir/all] Error 2

I again thank you for working on this, and apologies if I am making a mistake.

Here is the full log
log.txt (15.4 KB)

Hi,
what compiler/platform are you using?

gcc compiler: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
OS : Ubuntu 20.04.6 LTS x86_64
ROOT : 6.24/08 (Built for linuxx8664gcc)

If needed:
g++ compiler: g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0

Can you try adding extra curly braces in lines 138, 149, 150 and 161 of the file Include/Garfield/ComponentChargedRing.hh?

-  static constexpr double m_kEllipticKCoeffs[m_kTaylorOrder] = {
+  static constexpr double m_kEllipticKCoeffs[m_kTaylorOrder] = {{
-      2133423721.0 / 68719476736.0};
+      2133423721.0 / 68719476736.0}};
-  static constexpr double m_kEllipticECoeffs[m_kTaylorOrder] = {
+  static constexpr double m_kEllipticECoeffs[m_kTaylorOrder] = {{
-      -112285459.0 / 68719476736.0};
+      -112285459.0 / 68719476736.0}};

Seems like “make -j4” doesn’t like it. It gives the following errors:

In file included from input_line_9:12:
In file included from /home/d/Nuclear_phys4bash/Garfield/Include/Garfield/AvalancheGridSpaceCharge.hh:10:
/home/d/Nuclear_phys4bash/Garfield/Include/Garfield/ComponentChargedRing.hh:138:65: error: excess elements in scalar initializer
  static constexpr double m_kEllipticKCoeffs[m_kTaylorOrder] = {{
                                                                ^
/home/d/Nuclear_phys4bash/Garfield/Include/Garfield/ComponentChargedRing.hh:150:65: error: excess elements in scalar initializer
  static constexpr double m_kEllipticECoeffs[m_kTaylorOrder] = {{
                                                                ^

Please note that I did a fresh start by removing all the files and “git clone”-ing the project.

Here is the full log:
log.txt (2.6 KB)

Hmm… can you try changing

static constexpr double m_kEllipticKCoeffs[m_kTaylorOrder] = {{

to

static constexpr std::array<double, m_kTaylorOrder> m_kEllipticKCoeffs = {{

and

static constexpr double m_kEllipticECoeffs[m_kTaylorOrder] = {{

to

static constexpr std::array<double, m_kTaylorOrder> m_kEllipticECoeffs = {{

No success. Here is the error:

[ 43%] Linking CXX executable mwpc
[ 44%] Linking CXX executable ion_signal
/usr/bin/ld: ../../[ 44%] Linking CXX executable full_tpc_sim
libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/plot_gas.dir/build.make:108: Examples/AliceTPC/plot_gas] Error 1
make[1]: *** [CMakeFiles/Makefile2:2117: Examples/AliceTPC/CMakeFiles/plot_gas.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AnalyticField/CMakeFiles/mwpc.dir/build.make:108: Examples/AnalyticField/mwpc] Error 1
make[1]: *** [CMakeFiles/Makefile2:2213: Examples/AnalyticField/CMakeFiles/mwpc.dir/all] Error 2
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/ion_signal.dir/build.make:108: Examples/AliceTPC/ion_signal] Error 1
make[1]: *** [CMakeFiles/Makefile2:2149: Examples/AliceTPC/CMakeFiles/ion_signal.dir/all] Error 2
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticECoeffs'
/usr/bin/ld: ../../libGarfield.so.0.3: undefined reference to `Garfield::ComponentChargedRing::m_kEllipticKCoeffs'
collect2: error: ld returned 1 exit status
make[2]: *** [Examples/AliceTPC/CMakeFiles/full_tpc_sim.dir/build.make:108: Examples/AliceTPC/full_tpc_sim] Error 1
make[1]: *** [CMakeFiles/Makefile2:2181: Examples/AliceTPC/CMakeFiles/full_tpc_sim.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Hi again,
I’ve just merged a set of commits that I hope should fix your issue:

Can you do a git pull and try again?

It worked! I also successfully ran the GEM example as suggested on the installation page.

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