# Armadillo functions not working through Cling

**URL:** <https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036>\
**Category:** Cling\
**Created:** [April 17, 2024, 6:09pm UTC](https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036 "2024-04-17T18:09:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShadowOne333](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shadowone333/32/17182_2.png) [@ShadowOne333](https://root-forum.cern.ch/u/ShadowOne333)\
**Post date:** [April 17, 2024, 6:09pm UTC](https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036/1 "2024-04-17T18:09:11Z")

</div>

I’ve been trying to use Cling for the last week or so, and while C and C++ code seems to work just fine, I found some issues when trying to incorporate some additional libraries to use in my C++ code through Cling.

Armadillo is one of those, I have the exact same code for both the Cling-ran C++ code, and a compiled binary which uses the exact same code, with the only difference being the `#! /usr/bin/cling` line at the very beginning of the one ran through Cling.

Here’s the example code:

```auto
#include <iostream>
#include <fstream>
#include <armadillo>

using namespace std;
using namespace arma;

int a = 1;
vec z = vec(3);
mat A = mat(5,4);
ofstream test;

// Start code
int main(void)
{
	test.open("hello.txt");
	cout << "\nHello World!\n";
	test << z << "\n";
	test << z.t() << "\n";
	test << A.randu() << "\n";
	cout << A.randu() << "\n";
	cout << A << "\n";
	test.close();
}

```

What this does is create a size 3 vector, and a size 5,4 matrix.  
Trying to print out the matrix and vector by themselves (initialized as 0s) does work through Cling, but the very moment I try using `A.randu()` or any other Armadillo function to fill or work with the matrix/vector, Cling errors out and refuses to print the matrix/vector. I’m running the .cpp as an executable with the added `#! /usr/bin/cling` line at the beginning of it, and then running it in terminal as follows:

`$ ./hello.cpp -larmadillo`

Trying to print out the `A` matrix alone works with Cling, but using `A.randu()` throws the following on terminal:

```auto
ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
  LC_ALL=C ccache -O2 -DNDEBUG -xc++ -E -v /dev/null 2>&1 | sed -n -e '/^.include/,${' -e '/^ \/.*++/p' -e '}'
Results was:
With exit code 0
Warning in cling::IncrementalParser::CheckABICompatibility():
  Possible C++ standard library mismatch, compiled with __GLIBCXX__'20200723'
  Extraction of runtime standard library version was: '20240210'
IncrementalExecutor::executeFunction: symbol '__emutls_v._ZN4arma19mt19937_64_instanceE' unresolved while linking [cling interface function]!

```

For reference, compiling the exact same hello.cpp file with g++ with `g++ hello-comp.cpp -o hello-comp -larmadillo` does print out the matrix with the `.randu()` function added into it properly, both in terminal and in the hello.txt file. It’s only through Cling that it doesn’t print them out with the random values.

I was wondering if someone might know why this is happening, since I’m using the exact same code I compiled for Cling, and I added armadillo as a proper loaded library.

It’s worth noting that `z.t()` does work, but it simply transposes the 0s filled vertical vector to a 0s filled horizontal vector.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [April 17, 2024, 9:31pm UTC](https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036/2 "2024-04-17T21:31:02Z")

</div>

Hello!

Seems like you compiled armadillo with a different C++ standard. How did you get armadillo and ROOT?

Any library that you use in the ROOT interpreter needs to be compiled with the same C++ standard as ROOT itself:

> **[Building ROOT from source](https://root.cern/install/build_from_source/#caveats)**
>
> Data Analysis Framework

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![ShadowOne333](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shadowone333/32/17182_2.png) [@ShadowOne333](https://root-forum.cern.ch/u/ShadowOne333)\
**Post date:** [April 19, 2024, 3:01pm UTC](https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036/3 "2024-04-19T15:01:56Z")

</div>

Seems like adding the following line at the very start of the code makes the Armadillo functions work properly:

`#define ARMA_DONT_USE_WRAPPER`

I think that pretty much covers Armadillo, at least from my initial test.  
Now what I’m having trouble with is trying to use gnuplot-iostream with Cling:

```auto
In file included from input_line_8:1:
In file included from ./gnuplot-iostream.h:81:
In file included from /usr/include/boost/filesystem.hpp:16:
In file included from /usr/include/boost/filesystem/path.hpp:21:
In file included from /usr/include/boost/filesystem/detail/path_traits.hpp:25:
In file included from /usr/include/boost/system/error_category.hpp:11:
In file included from /usr/include/boost/system/detail/error_category_impl.hpp:15:
/usr/include/boost/system/detail/error_code.hpp:590:33: error: conversion function from 'boost::system::error_code' to 'const std::error_code' invokes a deleted function
            std::error_code e2( *this );
                                ^ ~~~~
/usr/include/boost/system/detail/error_code.hpp:579:5: note: 'operator error_code' has been explicitly marked deleted here
    operator std::error_code ()
    ^
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/system_error:245:33: note: passing argument to parameter here
    error_code(const error_code&) = default;
                                ^
In file included from input_line_8:1:
./gnuplot-iostream.h:155:23: warning: variable templates are a C++14 extension [-Wc++14-extensions]
static constexpr bool dont_treat_as_stl_container = false;
                      ^
./gnuplot-iostream.h:159:23: warning: variable templates are a C++14 extension [-Wc++14-extensions]
static constexpr bool is_like_stl_container = false;
                      ^
./gnuplot-iostream.h:162:48: error: no template named 'void_t' in namespace 'std'; did you mean 'boost::void_t'?
static constexpr bool is_like_stl_container<T, std::void_t<
                                               ^ ~~~~~~~~~~
                                               boost::void_t
/usr/include/boost/type_traits/make_void.hpp:25:1: note: 'boost::void_t' declared here
using void_t = typename make_void<Ts...>::type;
^
In file included from input_line_8:1:
./gnuplot-iostream.h:168:55: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert( is_like_stl_container<std::vector<int>>);
                                                      ^
                                                      , ""
./gnuplot-iostream.h:169:42: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert(!is_like_stl_container<int>);
                                         ^
                                         , ""
./gnuplot-iostream.h:173:23: warning: variable templates are a C++14 extension [-Wc++14-extensions]
static constexpr bool is_like_stl_container2 = false;
                      ^
./gnuplot-iostream.h:176:49: error: no template named 'void_t' in namespace 'std'; did you mean 'boost::void_t'?
static constexpr bool is_like_stl_container2<T, std::void_t<
                                                ^ ~~~~~~~~~~
                                                boost::void_t
/usr/include/boost/type_traits/make_void.hpp:25:1: note: 'boost::void_t' declared here
using void_t = typename make_void<Ts...>::type;
^
In file included from input_line_8:1:
./gnuplot-iostream.h:183:23: warning: variable templates are a C++14 extension [-Wc++14-extensions]
static constexpr bool is_boost_tuple_nulltype =
                      ^
./gnuplot-iostream.h:184:10: error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?
    std::is_same_v<T, boost::tuples::null_type>;
    ~~~~~^~~~~~~~~
         is_same
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/type_traits:1393:12: note: 'is_same' declared here
    struct is_same
           ^
In file included from input_line_8:1:
./gnuplot-iostream.h:184:48: error: expected '(' for function-style cast or type construction
    std::is_same_v<T, boost::tuples::null_type>;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
./gnuplot-iostream.h:183:23: error: constexpr variable declaration must be a definition
static constexpr bool is_boost_tuple_nulltype =
                      ^
./gnuplot-iostream.h:186:15: note: in instantiation of variable template specialization 'gnuplotio::is_boost_tuple_nulltype<boost::tuples::null_type>' requested here
static_assert(is_boost_tuple_nulltype<boost::tuples::null_type>);
              ^
./gnuplot-iostream.h:186:64: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert(is_boost_tuple_nulltype<boost::tuples::null_type>);
                                                               ^
                                                               , ""
./gnuplot-iostream.h:186:15: error: static_assert expression is not an integral constant expression
static_assert(is_boost_tuple_nulltype<boost::tuples::null_type>);
              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./gnuplot-iostream.h:189:23: warning: variable templates are a C++14 extension [-Wc++14-extensions]
static constexpr bool is_boost_tuple = false;
                      ^
./gnuplot-iostream.h:192:41: error: no template named 'void_t' in namespace 'std'; did you mean 'boost::void_t'?
static constexpr bool is_boost_tuple<T, std::void_t<
                                        ^ ~~~~~~~~~~
                                        boost::void_t
/usr/include/boost/type_traits/make_void.hpp:25:1: note: 'boost::void_t' declared here
using void_t = typename make_void<Ts...>::type;
^
In file included from input_line_8:1:
./gnuplot-iostream.h:197:49: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert( is_boost_tuple<boost::tuple<int>>);
                                                ^
                                                , ""
./gnuplot-iostream.h:197:16: error: static_assert expression is not an integral constant expression
static_assert( is_boost_tuple<boost::tuple<int>>);
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./gnuplot-iostream.h:183:23: error: constexpr variable declaration must be a definition
static constexpr bool is_boost_tuple_nulltype =
                      ^
./gnuplot-iostream.h:195:51: note: in instantiation of variable template specialization 'gnuplotio::is_boost_tuple_nulltype<boost::tuples::cons<int, boost::tuples::null_type> >'
      requested here
    >> = is_boost_tuple<typename T::tail_type> || is_boost_tuple_nulltype<typename T::tail_type>;
                                                  ^
./gnuplot-iostream.h:198:16: note: in instantiation of variable template specialization 'gnuplotio::is_boost_tuple<boost::tuples::tuple<int, int, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type>, void>' requested here
static_assert( is_boost_tuple<boost::tuple<int, int>>);
               ^
./gnuplot-iostream.h:195:10: error: constexpr variable 'is_boost_tuple<boost::tuples::tuple<int, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, void>' must
      be initialized by a constant expression
    >> = is_boost_tuple<typename T::tail_type> || is_boost_tuple_nulltype<typename T::tail_type>;
         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./gnuplot-iostream.h:198:16: note: in instantiation of variable template specialization 'gnuplotio::is_boost_tuple<boost::tuples::tuple<int, int, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type>, void>' requested here
static_assert( is_boost_tuple<boost::tuple<int, int>>);
               ^
./gnuplot-iostream.h:198:54: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert( is_boost_tuple<boost::tuple<int, int>>);
                                                     ^
                                                     , ""
./gnuplot-iostream.h:198:16: error: static_assert expression is not an integral constant expression
static_assert( is_boost_tuple<boost::tuple<int, int>>);
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./gnuplot-iostream.h:198:16: note: initializer of 'is_boost_tuple<boost::tuples::tuple<int, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
      boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, void>' is not
      a constant expression
./gnuplot-iostream.h:192:23: note: declared here
static constexpr bool is_boost_tuple<T, std::void_t<
                      ^
./gnuplot-iostream.h:199:47: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert(!is_boost_tuple<std::tuple<int>>);
                                              ^
                                              , ""
./gnuplot-iostream.h:200:52: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert(!is_boost_tuple<std::tuple<int, int>>);
                                                   ^
                                                   , ""
./gnuplot-iostream.h:575:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<is_boost_tuple<T>>
    ~~~~~~~~~~~~~~^~~~~~~~~~~./gnuplot-iostream.h:588:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<is_boost_tuple<T>>
    ~~~~~~~~~~~~~~^~~~~~~~~~~./gnuplot-iostream.h:601:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<is_boost_tuple<T>>
    ~~~~~~~~~~~~~~^~~~~~~~~~~./gnuplot-iostream.h:805:33: error: no template named 'conditional_t' in namespace 'std'; did you mean 'boost::conditional_t'?
    using value_type = typename std::conditional_t<is_container, Error_InappropriateDeref, TV>;
                                ^ ~~~~~~~~~~~~~~~~~
                                boost::conditional_t
/usr/include/boost/type_traits/conditional.hpp:21:40: note: 'boost::conditional_t' declared here
   template <bool b, class T, class U> using conditional_t = typename conditional<b, T, U>::type;
                                       ^
In file included from input_line_8:1:
./gnuplot-iostream.h:837:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<is_like_stl_container<T>>
    ~~~~~~~~~~~~~~^~~~~~~~~~~./gnuplot-iostream.h:849:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<is_like_stl_container2<T>>
    ~~~~~~~~~~~~~~^~~~~~~~~~~./gnuplot-iostream.h:948:19: error: no type named 'enable_if_t' in namespace 'std'
    typename std::enable_if_t<
    ~~~~~~~~~~~~~~^~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]

```

Compiling the same code normally with g++ does work without any errors, it’s only through Cling that these appear.  
Should I open a new thread for the gnuplot errors or can I continue in this one?

---

<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:** [May 3, 2024, 3:02pm UTC](https://root-forum.cern.ch/t/armadillo-functions-not-working-through-cling/59036/4 "2024-05-03T15:02:13Z")

</div>

Closed on May 3, 2024, 3:02pm UTC

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