1

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!

user2416984
  • 941
  • 1
  • 11
  • 18
  • My guess would be that KDevelop has a different environment, I don't have it in-front of me so you should just poke around some options and see if it overrides something. Or if you changed `LD_LIBRARY_PATH` recently enough that your session where KDevelop was started does not reflect that. – r_ahlskog Jan 28 '14 at 15:31

2 Answers2

2

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

Exploring
  • 2,493
  • 11
  • 56
  • 97
Danduk82
  • 769
  • 1
  • 10
  • 29
  • Thanks Danduk82, I added the folder in which the `libmkl_intel_lp64.so` was situated according to `ldd` in a new .conf file in the `etc/ld.so.conf/` folder, run `ldconfig -v` and that worked for me. Didn't know that the LD_LIBRARY_PATH is deprecated... I cannot vote up because I don't have enough reputation yet, sorry for this! – user2416984 Jan 29 '14 at 15:00
  • great, maybe you could accept the answer to close the thread ;) cheers – Danduk82 Jan 29 '14 at 17:32
0

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
    
Tunaki
  • 132,869
  • 46
  • 340
  • 423
N. S.
  • 159
  • 7