<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="im" style>Hi Mike:</div><div class="im" style><br></div><div class="im" style>Sorry that you'll get this twice.  The first time around I accidentally replied only to you.  Please read on for responses inline.</div>
<div class="im" style><br></div><div class="im">On Sun, Mar 31, 2013 at 4:08 PM, Mike Miller <span dir="ltr"><<a href="mailto:mtmiller@ieee.org" target="_blank">mtmiller@ieee.org</a>></span> wrote:<br></div><div class="gmail_extra">
<div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">CC'ing pkg-octave-devel since this impacts Octave packaging as well.</blockquote>

<div><br></div></div><div>Thanks.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>

Bradley M. Froehle wrote:<br>
> The fix for this bug provided in 1.8.9-1~exp2 has cause me a good deal of<br>
> headache today.<br>
><br>
> For me, the issue is triggered as some C++ code containing:<br>
><br>
> #include <hdf5.h>   // sets OMPI_SKIP_MPICXX 1<br>
> #include <mpi.h>  // MPI C++ namespace now is NOT available<br>
><br>
> Note that even trying to unset OMPI_SKIP_MPICXX before including mpi.h<br>
> won't work<br>
> because OMPI_MPI_H will still be defined and the mpi.h header won't be<br>
> processed again.<br>
<br>
</div>If you switch the order so mpi.h is included first does that fix it?<br>
I'm not dismissing, just making sure I understand the problem.</blockquote><div><br></div><div style><span style="color:rgb(34,34,34)">As an example of how confounding this is, just consider a simple example:</span><br>
</div></div><div><br></div><div>
<div>$ cat test.cpp</div><div>#include <hdf5.h></div><div>#include <mpi.h></div><div>int main() {</div><div>  MPI::Init();</div><div>  printf("I'm %d of %d\n", MPI::COMM_WORLD.Get_rank(), MPI::COMM_WORLD.Get_size());</div>

<div>  MPI::Finalize();</div><div>}</div><div><br></div><div>$ mpicxx -o test test.cpp</div><div>test.cpp: In function ‘int main()’:</div><div>test.cpp:4:3: error: ‘MPI’ has not been declared</div><div>test.cpp:5:28: error: ‘MPI’ has not been declared</div>

<div>test.cpp:5:56: error: ‘MPI’ has not been declared</div><div>test.cpp:6:3: error: ‘MPI’ has not been declared</div><div><br></div><div>Reversing the order of the includes as you suggest does allow the compilation to succeed.  My objection is primarily to the confusing nature of the failure --- it's not at all clear what went wrong or why.  I had to run the compiler with -E and search through the preprocessed source to see that the mpicxx.h header wasn't being included, then look to see the condition by which it would be included, and then track down why those conditions were not being met.  A lot of grepping led to the H5public.h header which I eventually tracked back to this issue.  (Obviously the case where I hit this was a lot more complicated than the toy example above and it wasn't even clear initially that I should look into HDF5).</div>

<div> <br></div></div><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>> Normally this is not an issue --- a developer would use mpicc or mpicxx to<br>

</div><div>
> do the compilation<br>
> and linking and this would automatically ensure that the correct mpi<br>
> libraries are used.  Octave<br>
> is broken because it is using g++ and hacking in the MPI include directory<br>
> without following it<br>
> up with the necessary link flags.<br>
<br>
</div>Octave is not broken, it is simply using HDF5 in a C++ source file and<br>
does not care about or use MPI. However we do want to support<br>
co-installation for users that do want both Octave and MPI. Octave<br>
shouldn't have to care which flavor of HDF5 is installed. Consider<br>
these simple examples:<br>
<br>
$ cat hdf5test.c<br>
#include <hdf5.h><br>
// C source file follows<br>
main() {}<br>
<br>
$ cat hdf5test.cc<br>
#include <hdf5.h><br>
// C++ source file follows<br>
main() {}<br>
<br>
$ gcc -o hdf5test hdf5test.c -lhdf5<br>
$ g++ -o hdf5test hdf5test.cc -lhdf5<br></blockquote><div><br></div></div><div>Yes, that is correct.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Works if libhdf5-7 and libhdf5-dev are installed. If HDF5 were<br>
providing a consistent interface this would also work with<br>
libhdf5-openmpi-7 and libhdf5-openmpi-dev installed. As it stands now,<br>
however, I need to compile with (assuming the patch is reverted)<br>
<br>
$ gcc -I/usr/include/mpi -o hdf5test hdf5test.c -lhdf5<br>
$ g++ -I/usr/include/mpi -DOMPI_SKIP_MPICXX -o hdf5test hdf5test.cc -lhdf5<br>
or<br>
$ g++ -I/usr/include/mpi -o hdf5test hdf5test.cc -lhdf5 -lmpi++ -lmpi<br></blockquote><div><br></div></div><div>No, I believe this is wrong. Since hdf5-openmpi needs MPI, you should be compiling with<br></div><div>$ mpicc -o hdf5test hdf5test.c -lhdf5</div>

<div>$ mpicxx -o hdf5test hdf5test.cc -lhdf5</div><div><br></div><div>This means that another solution to the mkoctfile problem would be to invoke it as</div><div>  CXX=mpicx mkoctfile ...</div><div>
when compiling C++ code which directly (or indirectly) uses MPI.</div><div><br></div><div>Cheers,<br></div><div>Brad</div></div></div></div>
</div><br></div>