Question

I am trying to use the Intel MKL libraries for the first time. I am using CMake to build a simple project in which MKL is used. I work in the KDevelop 4.6 environment.

The project is built and installed without errors. Linking the libraries is thus succesful. While executing within KDevelop, I get the following error:

Error while loading shared libraries: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory

The CMakeLists file looks essentially as follows:

project(testmkl)

cmake_minimum_required(VERSION 2.6)

enable_language(Fortran)

set(CMAKE_C_FLAGS "-std=c99 -Wall -lpthread") 
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# MKL
find_package(MKL REQUIRED)
include_directories(${MKL_INCLUDE_DIR})

find_package(M REQUIRED)
include_directories(${M_INCLUDES})

add_executable(testmkl ./main.c)
target_link_libraries(testmkl ${M_LIBRARIES} ${MKL_BLAS} ${MKL_LAPACK} ${MKL_INTEL} ${MKL_SEQUENTIAL} ${MKL_CORE})
install(TARGETS testmkl DESTINATION .)

libmkl_intel_lp64.so is found in the first folder of the LP_LIBRARY_PATH environment variable, so I wouldn't expect any error during the execution. Actually, when running the program from the command window, everything seems to work fine.

The ldd output for the executable is:

>> ldd ./testmkl
linux-vdso.so.1 =>  (0x00007fff951fe000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003061a00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003061200000)
libmkl_intel_lp64.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_intel_lp64.so (0x00007f6f65ef6000)
libmkl_sequential.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_sequential.so (0x00007f6f65846000)
libmkl_core.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_core.so (0x00007f6f64317000)
libc.so.6 => /lib64/libc.so.6 (0x0000003060e00000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003060600000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003061600000)

The linked libraries are thus correctly found. Why won't the program work in the KDevelop environment?

Any help is welcome, thanks!

Was it helpful?

Solution

First one short question: are you excuting your program from a terminal or trying to execute from KDE gui (e.g. by double-click)?

On many linux OS, now LD_LIBRARY_PATH is deprecated. LD finds the dependencies thanks to what is listed in /etc/ld.so.conf and /etc/ld.so.conf.d . You may have to add a script somewhere there to include your libraries. In fact you just have to add the path to your libraries in those scripts.

example from /etc/ld.so.conf/libc.conf:

# libc default configuration
/usr/local/lib

This may work for you.

edit: you shoud also run ldconfig to update the LD database and/or use ldconfig -v, which does the same but with extended output

edit2: ldconfig may require root privileges to be understood by the GUI

OTHER TIPS

I had the same problem and now it solved through configuration of environment variable in kdevelop.

  1. Go to project->open configuration
  2. Select make tab
  3. Click setting icon in Active environment profile bar and add your environment variable:

    LD_LIBRARY_PATH = /your/shared/library/path
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top