Hello,

I have a slight problem linking against a local installation of mpi using 
cmake. It doesn't work in the way I was expected. It seems that FindMPI is able 
to locate the library but strip the linker of the informations concerning the 
directory containing the actual libraries.

Any help will be greatly appreciated.
You will find all the informations concerning the problem below.

Thank you in advance.

Best regards,

Christophe

Here is the CMakeLists.txt
cmake_minimum_required (VERSION 2.8.7)

# guard against in-source builds

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  message(FATAL_ERROR "In-source builds not allowed. Please make a new 
directory (called a build directory) and run CMake from there. You may need to 
remove CMakeCache.txt. ")
endif()

FIND_PACKAGE(MPI)
IF ( MPI_FOUND )
  SET(CMAKE_REQUIRED_INCLUDES "${MPI_INCLUDE_PATH};${CMAKE_REQUIRED_INCLUDES}")
  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
ENDIF()
add_executable(test_mpi test_mpi.cpp)
message(STATUS "My exec libs ${LINK_LIBRARIES}")
target_link_libraries(test_mpi ${MPI_LIBRARIES})


Then the output of the generation
picard@odysse:build$ cmake  ../Sources/
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /opt/GNU-Compilers/install/4.6.2/bin/gcc
-- Check for working C compiler: /opt/GNU-Compilers/install/4.6.2/bin/gcc -- 
works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/GNU-Compilers/install/4.6.2/bin/c++
-- Check for working CXX compiler: /opt/GNU-Compilers/install/4.6.2/bin/c++ -- 
works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found MPI_C: 
/opt/MPI/install-gnu/openmpi-1.5.4-gnu-4.6.2/lib/libmpi.so;/usr/lib/libdl.so;/usr/lib/libnsl.so;/usr/lib/libutil.so;/usr/lib/libm.so;/usr/lib/libdl.so
 
-- Found MPI_CXX: 
/opt/MPI/install-gnu/openmpi-1.5.4-gnu-4.6.2/lib/libmpi_cxx.so;/opt/MPI/install-gnu/openmpi-1.5.4-gnu-4.6.2/lib/libmpi.so;/usr/lib/libdl.so;/usr/lib/libnsl.so;/usr/lib/libutil.so;/usr/lib/libm.so;/usr/lib/libdl.so
 
-- My exec libs 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/picard/build-feel
picard@odysee:buildl$ make -j 12Scanning dependencies of target test_mpi
[100%] Building CXX object CMakeFiles/test_mpi.dir/test_mpi.cpp.o
Linking CXX executable test_mpi
[100%] Built target test_mpi

And the linking informations for the built object
picard@odysee:build$ ldd test_mpi 
        linux-vdso.so.1 =>  (0x00007fff2edff000)
        libmpi_cxx.so.0 => /usr/lib/libmpi_cxx.so.0 (0x00007fa2f3246000)
        libmpi.so.0 => /usr/lib/libmpi.so.0 (0x00007fa2f2f95000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007fa2f2d91000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00007fa2f2b79000)
        libutil.so.1 => /lib/libutil.so.1 (0x00007fa2f2976000)
        libm.so.6 => /lib/libm.so.6 (0x00007fa2f26f3000)
        libstdc++.so.6 => /opt/GNU-Compilers/install/4.6.2/lib64/libstdc++.so.6 
(0x00007fa2f23ef000)
        libgcc_s.so.1 => /opt/GNU-Compilers/install/4.6.2/lib64/libgcc_s.so.1 
(0x00007fa2f21da000)
        libc.so.6 => /lib/libc.so.6 (0x00007fa2f1e77000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007fa2f1c5b000)
        libopen-rte.so.0 => /usr/lib/libopen-rte.so.0 (0x00007fa2f1a0f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa2f3476000)
        libopen-pal.so.0 => /usr/lib/libopen-pal.so.0 (0x00007fa2f17b9000)

And the generated link.txt
/opt/GNU-Compilers/install/4.6.2/bin/c++       
CMakeFiles/test_mpi.dir/test_mpi.cpp.o  -o test_mpi -rdynamic -lmpi_cxx -lmpi 
-ldl -lnsl -lutil -lm -ldl -lnsl -lutil -lm  
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to