2

I'm trying to create a C++ Jupyter Notebook using xeus-cling and mybinder. I wanted to include the library armadillo and I was able to do that locally in a Jupyter Notebook as follows:

#pragma cling add_library_path("armadillo-10.7.5")
#pragma cling add_include_path("armadillo-10.7.5/include/")
#pragma cling load("armadillo")

#include <armadillo>

using namespace std;
using namespace arma;

mat A(4, 5, fill::randu);
mat B(4, 5, fill::randu);
  
cout << A*B.t() << endl;

where the file structure is as it's in this Github repository (you can also find the binder link in README): https://github.com/AntonioDaSilva/xeus-cling

However, armadillo requires the libraries OpenBLAS and LAPACK which I cannot install on mybinder since I do not have admin privileges. I believe this is the reason I get the following error when I run the code above in the binder:

cling::DynamicLibraryManager::loadLibrary(): libblas.so.3: cannot open shared object file: No such file or directory
IncrementalExecutor::executeFunction: symbol 'dgemv_' unresolved while linking function '_GLOBAL__sub_I_cling_module_6'!
IncrementalExecutor::executeFunction: symbol 'dsyrk_' unresolved while linking function '_GLOBAL__sub_I_cling_module_6'!
IncrementalExecutor::executeFunction: symbol 'ddot_' unresolved while linking function '_GLOBAL__sub_I_cling_module_6'!
IncrementalExecutor::executeFunction: symbol 'dgemm_' unresolved while linking function '_GLOBAL__sub_I_cling_module_6'!

Can you please help me figure out how to include these libraries manually in the binder?

1 Answers1

1

I suspect you can add an apt.txt configuration file to your repo with the following contents based on here:

libblas-dev
liblapack-dev

That may not quite be the current ones to list and so you may need to look around more to find the current best ones for installing with apt-get in current linux systems; however, that's the idea.

See more about the apt.txt configuration file use in the bottom of this reply on the Jupyter Discourse forum here.

(There is currently an issue when using apt.txt and install.R in combination, see here. I think this is specific to R installs; however, I thought I'd mention it in case you see issues upon adding apt.txt. I suspect it would be fixed in a few days.)


By the way, for everyone seeing this. There's a more suitable channel for getting help with this type of thing as it is very specific and not general to installing onto linux. At the Jupyter Discourse community forum there's a category of 'repo help' for Binder that you can post things like this and Jupyter/MyBinder folks will see and can exchange ideas to help get you sorted.

Wayne
  • 6,607
  • 8
  • 36
  • 93
  • Thanks for the help! I was able to include BLAS and LAPACK with the `apt.txt` (and a bunch of other libraries that are not in the system) file, however, it still gives an error `cling::DynamicLibraryManager::loadLibrary(): libhdf5_serial.so.103: cannot open shared object file: No such file or directory` which is the only thing missing confirmed by running `ldd` on armadillo `.so` file. I installed `hdf5_serial` as well, however, it installs the `.100` instead of the `.103` version. How do you suggest I proceed? – AntonioDaSilva Jan 22 '22 at 17:55
  • Well at least my suggestion solved the initial problems you were hitting. I'm quite stumped about that one. I've been trying a lot of things in my fork to no avail. Any chance it is there on the system now and we could set a path to it like says [here](https://stackoverflow.com/a/64545505/8508004)? It's possible to use shell commands after build using `postBuild` and after launch using `start` configuration files. However, I'm not sure about cling too much. Any chance you could put that file in the repo like you tried with blas and lapack and then point at it using postBuild or start? – Wayne Jan 22 '22 at 18:36
  • I came across [this](https://github.com/piwheels/piwheels/issues/75) and [this](https://blog.piwheels.org/how-to-work-out-the-missing-dependencies-for-a-python-package/) but I kept striking out pursuing it. Maybe it makes more sense to you? – Wayne Jan 22 '22 at 18:50
  • I have also came across these pages when I searched online but they didn’t help. As far as I understand, the problem is not that the file doesn’t exist (because I found it with a `find` search through commands on Jupyter Notebook), but that it’s not `.103` but `.100`. Is there a way to specify that version when putting `libhdf5_serial` in `apt.txt`? – AntonioDaSilva Jan 22 '22 at 23:42
  • Now that I see it again, maybe I can put the version with dash as described in the link you sent me. I will give it a shot now. – AntonioDaSilva Jan 22 '22 at 23:44
  • Unfortunately, it did not work: it gives the error: `E: Unable to locate package libhdf5-103`. Maybe it's because the binder's system is not updated because the command `sudo apt-get install libhdf5-103` works perfectly fine in my local system. I will try to manually point to it as a final solution trial :) – AntonioDaSilva Jan 23 '22 at 00:10
  • 1
    For now, I just omitted hdf-5 in the cmake of armadillo and rebuild which finally resulted in a working version. – AntonioDaSilva Jan 23 '22 at 01:38