[ITK-users] Linking an external ITK module against LAPACK?

Matt McCormick matt.mccormick at kitware.com
Wed Apr 13 21:44:00 EDT 2016


Hi Davis,

The BridgeOpenCV module can now also be built externally and it can be
used as an example.

The initial find_package should be added to itk-module-init.cmake.

  https://github.com/InsightSoftwareConsortium/ITK/blob/f8b17356cecf1611894e0be25b2c3d9284646889/Modules/Video/BridgeOpenCV/itk-module-init.cmake

Then, define <module-name>_EXPORT_CODE_INSTALL,
<module-name>_EXPORT_CODE_BUILD, <module-name>_SYSTEM_INCLUDE_DIRS,
and <module-name>_SYSTEM_LIBRARY_DIRS  (if needed):

  https://github.com/InsightSoftwareConsortium/ITK/blob/f8b17356cecf1611894e0be25b2c3d9284646889/Modules/Video/BridgeOpenCV/CMakeLists.txt#L9-L22

The first two are CMake code that gets called when another module or
library uses your module. The second two add to the header search
directories or library search directories (-I and -L) when building
code in your module or against your module.

If your module creates a library, link to the dependent libraries in
src/CMakeLists.txt:

  https://github.com/InsightSoftwareConsortium/ITK/blob/f8b17356cecf1611894e0be25b2c3d9284646889/Modules/Video/BridgeOpenCV/src/CMakeLists.txt#L8

HTH,
Matt

On Wed, Apr 13, 2016 at 7:16 PM, DVigneault <davis.vigneault at gmail.com> wrote:
> All--
>
> I have an external ITK module ITK/src/Modules/External/ITKDVUtilities/.
> Additionally, I have written a group of classes which depend on VNL and
> LAPACK (subroutines which do not ship with VNL).  I've tested them in a
> project outside the ITK source tree linking against LAPACK.  I'd now like to
> use these classes in my ITK module, but am unclear on how to link my module
> against LAPACK.  Adding target_link_libraries(${itk-module}
> ${LAPACK-LIBRARIES}) to ITKDVUtilities/CMakeLists.txt gives me the following
> CMake configuration error:
>
> CMake Error at Modules/External/ITKDVUtilities/CMakeLists.txt:15
> (target_link_libraries):
>    Cannot specify link libraries for target "ITKDVUtilities" which is not
>    built by this project.
>
> But, of course, if I leave it out, I get a linker error:
>
> Undefined symbols for architecture x86_64:
>   "_dgees_", referenced from:
>       vnl_schur_decomposition<double>::solve() in
> ITKDVUtilitiesHeaderTest1.cxx.o
>   "_sgees_", referenced from:
>       vnl_schur_decomposition<float>::solve() in
> ITKDVUtilitiesHeaderTest1.cxx.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> make[2]: *** [bin/ITKDVUtilitiesHeaderTest1] Error 1
> make[1]: ***
> [Modules/External/ITKDVUtilities/CMakeFiles/ITKDVUtilitiesHeaderTest1.dir/all]
> Error 2
> make: *** [all] Error 2
>
> I've pasted below the full text of
> ITK/srs/Modules/External/ITKDVUtilities/CMakeLists.txt.  Thanks very much in
> advance for your help!
>
> Best,
>
> --Davis
>
> # ITK/srs/Modules/External/ITKDVUtilities/CMakeLists.txt
> cmake_minimum_required(VERSION 2.8.9)
>
> project(ITKDVUtilities)
>
> find_package(LAPACK REQUIRED)
>
> if(NOT ITK_SOURCE_DIR)
>   find_package(ITK REQUIRED)
>   list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
>   include(ITKModuleExternal)
> else()
>   itk_module_impl()
> endif()
>
> #target_link_libraries(${itk-module} ${LAPACK-LIBRARIES})
>
>
>
> --
> View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Linking-an-external-ITK-module-against-LAPACK-tp7588734.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users


More information about the Insight-users mailing list