my experience compiling against Trilinos on Ubuntu

I’m just embarking on a historic journey to learn a bit about the Trilinos math library.  To get started, I’ve gone through the hands-on tutorial a bit and after a few tries, I’ve gotten something compiled.

Trilinos 10.4 is available in the repositories for Ubuntu (11.10 confirmed). But Trilinos 10.8 is out now, so I had to build my own. Their instructions with CMAKE were quite good and the build process didn’t have too many hiccups. I found that the cmake gui is the way to go. Make sure you enable Didasko (the tutorial) in the cmake gui. When you do this, a few more Didasko options show up so you have to go enable those too.

What, in retrospect, should have been obvious from the documentation, the way to build your own programs against Trilinos is to use the Makefile.export files. Once built, there will be a Makefile.export.[PackageName] for each packages in the /build/packages directories. That file has all the variables needed to tell your custom Makefile how to include Trilinos. So, you take your makefile and just say “include Makefile.export.Epetra” for example. I used the makefile at the bottom of the previous link as a skeleton for my first sample program. One problem I ran into with the skeleton is that it includes the Makefile.export.Trilinos and my build of Trilinos was in a long-named folder and has all the packages enabled, so I kept getting

c++: error trying to exec '/usr/lib/gcc/x86_64-linux-gnu/4.6.1/collect2': execv: Argument list too long

This is because the argument list generated in my Trilinos makefile was literally 133469 characters long, and according to

xargs --show-limits

my limit is 131072. Too bad. I haven’t found out how to increase this limit other than recompiling the kernel, which I’m not about to do. Solution? Forget about the full Makefile and just add the packages I’m using. In this sample case, I’m compiling the first example from Didasko, ex1.cpp.

Another error I had was

ex1.cpp:35:32: fatal error: Didasko_ConfigDefs.h: No such file or directory

To get around that, I edited ex1.cpp and removed the outer #ifdef loop that provided the error message. This included removing calls to Didasko_ConfigDefs.h.

Final trick: In the skeletal Makefile, all the variables are defined as Trilinos_CXX, etc. When you include a specific package’s makefile, you have to change them to Epetra_CXX, etc. So I did a find/replace Trilinos->Epetra and hit make. Check it out:

Compiled! Sweet. More on this as it progresses.

Leave a Reply

Your email address will not be published. Required fields are marked *