<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=GB2312" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Bill Hoffman Ð´µÀ:
<blockquote cite="mid:4B06BF71.6080504@kitware.com" type="cite">
  <pre wrap="">¶­Àí wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">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(&lt;module&gt; &lt;module source file&gt;)

set_target_properties(&lt;module&gt;
    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_'
......
"
    </pre>
  </blockquote>
  <pre wrap=""><!---->That looks way to platform specific...

include_directories(${MKL_INCLUDE_DIRS})
target_link_libraries(&lt;module&gt;
${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(&lt;module&gt;  ${MSOLVE} ${MKLCORE}

You should find out where the symbol is defined...

nm -PA ${MKL_LIBRARIES}/*.a | grep dtrnlsp_init

-Bill
  </pre>
</blockquote>
<tt>Hi, Bill,<br>
<br>
I have changed cmake configuration to link shared libraries of Intel
MKL, as following:<br>
<br>
"<br>
find_package(MKL REQUIRED)<br>
include_directories(${MKL_INCLUDE_DIRS})<br>
link_directories(${MKL_LIBRARIES})<br>
target_link_libraries(&lt;module&gt;<br>
&nbsp;&nbsp;&nbsp; mkl_intel_lp64<br>
&nbsp;&nbsp;&nbsp; mkl_sequential<br>
&nbsp;&nbsp;&nbsp; mkl_core<br>
)<br>
"<br>
and it worked.<br>
<br>
PS: I have written a simplie FindMKL.cmake.<br>
<br>
Best regards,<br>
<br>
DONG Li<br>
</tt>
</body>
</html>