[CMake] How to link Intel MKL
董理
dongli2020 at gmail.com
Sat Nov 21 09:14:47 EST 2009
Bill Hoffman 写道:
> 董理 wrote:
>
>> Hi, all,
>>
>> My program (Fortran 90) uses the "trust region nonlinear least squares
>> problem" (dtrnlsp) subroutines, how can I setup cmake?
>>
>> There is a module that calls the dtrnlsp subroutines, and one main
>> program uses that module.
>>
>> I have wrote the following statement in the CMakeLists.txt with module:
>> "
>> add_library(<module> <module source file>)
>>
>> set_target_properties(<module>
>> PROPERTIES
>> LINK_FLAGS "-I${MKL_INCLUDE_DIRS} -Wl,--start-group
>> ${MKL_LIBRARIES}/libmkl_solver_lp64_sequential.a
>> ${MKL_LIBRARIES}/libmkl_core.a -Wl,--end-group"
>> )
>> "
>> where MKL_INCLUDE_DIRS and MKL_LIBRARIES are set to the correct path.
>> The error output is:
>> "
>> ......
>> ...... undefined reference to `dtrnlsp_init_'
>> ......
>> "
>>
> That looks way to platform specific...
>
> include_directories(${MKL_INCLUDE_DIRS})
> target_link_libraries(<module>
> ${MKL_LIBRARIES}/libmkl_solver_lp64_sequential.a
> ${MKL_LIBRARIES}/libmkl_core.a )
>
> Or, this would be even better:
>
> find_library( MSOLVE mkl_solver_lp64_sequential HINTS ${MKL_LIBRARIES})
> find_library( MKLCORE mkl_core HINTS ${MKL_LIBRARIES})
> target_link_libraries(<module> ${MSOLVE} ${MKLCORE}
>
> You should find out where the symbol is defined...
>
> nm -PA ${MKL_LIBRARIES}/*.a | grep dtrnlsp_init
>
> -Bill
>
Hi, Bill,
I have changed cmake configuration to link shared libraries of Intel
MKL, as following:
"
find_package(MKL REQUIRED)
include_directories(${MKL_INCLUDE_DIRS})
link_directories(${MKL_LIBRARIES})
target_link_libraries(<module>
mkl_intel_lp64
mkl_sequential
mkl_core
)
"
and it worked.
PS: I have written a simplie FindMKL.cmake.
Best regards,
DONG Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091121/5a3384ac/attachment.htm>
More information about the CMake
mailing list