Opened 12 years ago

Last modified 12 years ago

#2329 new defect

[patch] Incorrect MPI header path in CMake file

Reported by: bradh Owned by: kmelero
Priority: normal Milestone: OSSIM 2.0
Component: Other Version:
Severity: normal Keywords:
Cc:

Description

When trying to build ossim trunk on Linux, using cmake 2.8, I hit this issue:

[  1%] Building CXX object ossim/src/ossim/CMakeFiles/ossim.dir/parallel/ossimIgen.cpp.o
cd /home/bradh/ossim/ossim_package_support/cmake/build/ossim/src/ossim && /usr/bin/c++   -Dossim_EXPORTS -DOSSIMMAKINGDLL -O3 -DNDEBUG -fPIC -I/home/bradh/ossim/ossim/include -I/home/bradh/ossim/ossim_package_support/cmake/build/ossim/include -I/usr/local/include -I/usr/include/geotiff -I/usr/include/freetype2     -o CMakeFiles/ossim.dir/parallel/ossimIgen.cpp.o -c /home/bradh/ossim/ossim/src/ossim/parallel/ossimIgen.cpp
/home/bradh/ossim/ossim/src/ossim/parallel/ossimIgen.cpp:15:19: fatal error: mpi.h: No such file or directory

I think the problem is that we're not using the correct CMake variable for the MPI header path. The documentation says:

# This module will set the following variables per language in your project,
# where <lang> is one of C, CXX, or Fortran:
#   MPI_<lang>_FOUND           TRUE if FindMPI found MPI flags for <lang>
#   MPI_<lang>_COMPILER        MPI Compiler wrapper for <lang>
#   MPI_<lang>_COMPILE_FLAGS   Compilation flags for MPI programs
#   MPI_<lang>_INCLUDE_PATH    Include path(s) for MPI header
#   MPI_<lang>_LINK_FLAGS      Linking flags for MPI programs
#   MPI_<lang>_LIBRARIES       All libraries to link MPI programs against

So I think we should use ${MPI_C_INCLUDE_PATH} (or the fallback ${MPI_INCLUDE_PATH}) instead of ${MPI_INCLUDE_DIR}.

Fixing that, I hit:

[ 49%] Building CXX object ossim/src/apps/ossim-pixelflip/CMakeFiles/ossim-pixelflip.dir/ossim-pixelflip.cpp.o                                                                                  
Linking CXX executable ../../../../Release/ossim-pixelflip                                                                                                                                      
/usr/bin/ld: CMakeFiles/ossim-pixelflip.dir/ossim-pixelflip.cpp.o: undefined reference to symbol 'MPI_Type_indexed'                                                                             
/usr/bin/ld: note: 'MPI_Type_indexed' is defined in DSO /usr/lib/libmpi.so.0 so try adding it to the linker command line
/usr/lib/libmpi.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [Release/ossim-pixelflip] Error 1
make[1]: *** [ossim/src/apps/ossim-pixelflip/CMakeFiles/ossim-pixelflip.dir/all] Error 2
make: *** [all] Error 2

However that might be one of the "openmpi doesn't work" problems.

Anyway:

--- ossim/CMakeLists.txt        (revision 21962)
+++ ossim/CMakeLists.txt        (working copy)
@@ -126,7 +126,7 @@
 if( BUILD_OSSIM_MPI_SUPPORT )
    find_package(MPI)
    if ( MPI_FOUND )
-      include_directories( ${MPI_INCLUDE_DIR} )
+      include_directories( ${MPI_INCLUDE_PATH} )
       set( ossimDependentLibs ${ossimDependentLibs} ${MPI_LIBRARY} )
       set( OSSIM_HAS_MPI 1 )
    else ( MPI_FOUND )

Change History (1)

comment:1 by bradh, 12 years ago

Looks like I needed this patch instead:

Index: ossim/CMakeLists.txt
===================================================================
--- ossim/CMakeLists.txt        (revision 21962)
+++ ossim/CMakeLists.txt        (working copy)
@@ -126,8 +126,8 @@
 if( BUILD_OSSIM_MPI_SUPPORT )
    find_package(MPI)
    if ( MPI_FOUND )
-      include_directories( ${MPI_INCLUDE_DIR} )
-      set( ossimDependentLibs ${ossimDependentLibs} ${MPI_LIBRARY} )
+      include_directories( ${MPI_INCLUDE_PATH} )
+      set( ossimDependentLibs ${ossimDependentLibs} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY} )
       set( OSSIM_HAS_MPI 1 )
    else ( MPI_FOUND )
       message( WARNING "Could not find optional MPI package!" )
Note: See TracTickets for help on using tickets.