I want to try and link Armadillo (an open source linear algebra library) with root
but I have never linked libraries before so any (if possible) detailled assistance on how to do this step by step would be much appreciated.
I have currently managed to install armadillo and it seems to runs fine from the compiler. I found the instructions for LAPACK on a different thread
[url]ROOT and Lapack++
where they executed the following commands:
//this is the main header
but I dont know where to find the analogous files for my case
any help would be much appreciated’
(Try to find appropriate “lapackpp” binary and development packages for your system. if not found, you will need to compile and install it yourself.)
Hi Pepe Le Pew,
sorry for not being clear, I didnt mean that I wanted LAPACK, rather I have a library Armadillo already installed and running on my machine. I would now like to link this with ROOT cint in an analogous way to what was shown in the link for LAPACK. How would I go about doing this?
The library seems to be named libarmadillo.so but the header file are a bit more complex than lapack.
The extra complexity (many many nested header as far as I can tell) means that instead of relying on the default behavior of ACLiC (generate the dictionary for the entity declare in the header itself), you will need to write a linkdef file requesting the symbol you need. For example by write a file name amardillo_linkdef.h and doing:
.L amardillo.h+(apparently their header those not have the .h in its name so you will need to write a file name ‘amardillo.h’ than contains just #include )
The file amardillo_linkdef.h would be something like (see the User’s Guide and the CINT documentation for more details):
#pragma link C++ function this_or_that(double);
Thanks for the help…
So I get the following error:
root  gSystem->Load("libarmadillo.so");
Error in <TUnixSystem::DynamicPathName>: libarmadillo.so does not exist in /Users/Maki/root/lib:/Users/Maki/root/lib::/Users/Maki/root/lib::.:/Users/Maki/root/lib::/Users/Maki/root/cint/cint/stl
is this because the library is dynamic? I have .dylib files but cant find any .so files for armadillo?
That is either because it has not been built yet (as part of amardillo) or the location it is installed in is not in your LD_LIBRARY_PATH.
sorry I should have mentioned that I am running this on a mac osx 10.5 and at least from other threads [url]Loading MacOS dylibs in CINT this seems to be a common problem. So I have now symlinked libarmadillo.dylib with .so
but I now get the following error:
dlopen error: dlopen(/usr/local/lib/liblapackpp.so, 9): no suitable image found. Did find:
/usr/local/lib/liblapackpp.so: mach-o, but wrong architecture
/usr/local/lib/liblapackpp.so: mach-o, but wrong architecture
Load Error: Failed to load Dynamic link library /usr/local/lib/liblapackpp.so
Running lipo -info I find
Non-fat file: libarmadillo.dylib is architecture: i386
but I’m not sure why this is a problem. Again thanks for the help
The default on mac is to build ROOT in 64 bits mode. You need to either rebuild amardillo in 64 bit mode or rebuild ROOT In 32 bit mode.
Great thanks for your help.
I have tried to rebuild armadillo in64bit mode but that seemed to have failed so I will try to rebuild root. The problem when I download the source there is no configure file. Also how do I specify the build to be 32 bit?
so I have rebuild root in 32bit mode and I believe I can successfully load the library. But there seems to be a few problems let me just list what I have done so far:
- so my library is in /usr/local but when I load the library it couldn’t find it so I added the LD_LIBRARY_PATH (export LD_LIBRARY_PATH = /usr/local/lib:$LD_LIBRARY_PATH) but that still didn’t solve the problem so I need to do the following
and that seems to work.
- I added the files armadillo.h and the armadillo_linkdef.h files to my current directory (is that where they should be?) and I get the following error
root  gSystem->Load("/usr/local/lib/libarmadillo.so");
root  .L armadillo.h+
Info in <TUnixSystem::ACLiC>: creating shared library /Users/Maki/Desktop/armadillo-3.2.4/examples/./armadillo_h.so
In file included from /usr/local/include/armadillo:104,
/usr/local/include/armadillo_bits/typedef.hpp:48:4: error: #error "don't know how to typedef 'u32' on this system"
Error: external preprocessing failed. :0:
!!!Removing /Users/Mark/Desktop/armadillo-3.2.4/examples/armadillo_h_ACLiC_dict.cxx /Users/Mark/Desktop/armadillo-3.2.4/examples/armadillo_h_ACLiC_dict.h !!!
Error: /Users/Mark/root/bin/rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: Invoking compiler to check macro's validity
Info in <ACLiC>: The compiler has not found any problem with your macro.
Probably your macro uses something rootcint can't parse.
Check http://root.cern.ch/root/Cint.phtml?limitations for Cint's limitations.
and this is where I am stuck…
Also I had a question in regards to the linkdef file - do I need to add every class/function I call in this file for example:
#pragma link C++ class Mat<double>;
cheers and thanks again for your help really appreciate it…
export LD_LIBRARY_PATH = /usr/local/lib:$LD_LIBRARY_PATHTry without the space around the = sign.
[quote]/usr/local/include/armadillo_bits/typedef.hpp:48:4: error: #error “don’t know how to typedef ‘u32’ on this system”[/quote]That’s a bit odd. Check in $ROOTSYS/include/compiledata.h which compiler has been used for compiling ROOT (i.e. g++ or clang). Make sure it is the same one as the one used for amardillo. If it is the same. Try compiling simple example for amardillo (arma.sourceforge.net/docs.html#example_prog)
[quote]do I need to add every class/function I call in this file for example:[/quote]Only the one you want to be able to use from the command prompt or you want to store in a ROOT file.
Also we recommend requesting the newer I/O implementation (with the trailing +):
#pragma link C++ class Mat<double>+;
Okay without the spaces is works
The compiler used for ROOT was g++
I’m not sure where I can find the same information for armadillo…
but if I try to run a simple example I get the same error message as before.
[quote]but if I try to run a simple example I get the same error message as before.
[/quote]So this is definitely an issue with amardilo which is not configured (properly?) to run with g++. At this point you will need to contact the amardilo support team for more details (note that ROOT can also be build with clang).
thanks a lot for your help… although I didnt manage to get it working with CINT
I have got it working from the compiler so Im not sure what the issue is but it is at least working.