As usual I have spoken too fast … (or maybe not). I am so sorry to require your help so much ^^.
The compilation stage went fine either with MPI enabled or not. But errors appeared when I tried to split the code using palabos in several files.
Let’s say I have 2 files, main.cpp and function.cpp which look like this
main.cpp :
#include "palabos2D.h"
#include "palabos2D.hh"
void aFunction(plb::MultiBlockLattice2D<...>) ;
int main( int argc, char** argv) {
// ...
aFunction(lattice)
}
function.cpp :
#include "palabos2D.h"
#include "palabos2D.hh"
void aFunction(plb::MultiBlockLattice2D<...> lattice) {
initializeAtEquilibrium(lattice, ... ) ;
}
As far as I understand, the palabos2D.h includes the palabos usual library declarations and the palabos2D.hh the templates declaration and definitions (since you cannot separate them with templates).
Tough, the linker trows out errors due to ‘multiple definitions’, mainly in core/blockIdentifiers.hh.
If I remove the #include “palabos2D.hh” from functions.cpp, these error messages dissapears but the linker complains about undefined reference to initializeAtEquilibrium. Which is normal, because the template function needed is not instanciated in function.o (which now lacks the template definitions in palabos2D.hh), nor in main.o (which does not call this function at all).
So the only workaround is to instanciate the template function in main.cpp like this.
main.cpp :
#include "palabos2D.h"
#include "palabos2D.hh"
void aFunction(plb::MultiBlockLattice2D<...>) ;
namespace plb{
template initializeAtEquilibrium<some types>(...);
}
int main( int argc, char** argv) {
// ...
aFunction(lattice)
}
function.cpp :
#include "palabos2D.h"
void aFunction(plb::MultiBlockLattice2D<...> lattice) {
initializeAtEquilibrium(lattice, ... ) ;
}
Still, I think that this is probably not like this that it was meant to be done. Am I missing something, or is it the way the library is designed that causes this behaviour ?
Thanks in advance 