[ITK] compiling itk on freebsd, how to flag out ldl?

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Wed Feb 22 09:41:22 EST 2017


Hello Longzhu,

We have address the issue in ITK:
http://review.source.kitware.com/#/c/22080/

And updated the SimpleITK master branch to use this patched version of ITK. You may need to do a "git checkout master && git pull"

If you checkout the current SimpleITK master, I expect that is should just compile and build with the default options. However, to ensure it works I’d recommend the following initial configuration line:

$ cmake -DITK_DYNAMIC_LOADING:BOOL=0 -DCMAKE_DL_LIBS=“” ../SimpleITK/SuperBuild

That should work for you now. Please give it a try and report back.

Thanks for trying out SimpleITK!
Brad

 cmake ../SuperBuild -DITK_DYNAMIC_LOADING:BOOL=0

On Feb 15, 2017, at 6:52 AM, Lowekamp, Bradley (NIH/NLM/LHC) [C] <blowekamp at mail.nih.gov<mailto:blowekamp at mail.nih.gov>> wrote:

It looks like our e-mails crossed last night.

I think you were really close to building building SimpleITK. If your goal is to use the SimpleITK language binding I would recommend continuing to use the SimpleITK superbuild. From your previous message the Superbuild compiled all of ITK, and the SimpleITK libraries, and maybe even the SimpleITK testing too. It just appears to have failed on linking for the Tcl wrapping.

When you do the Superbuild of SimpleITK it automatically downloads the correct version of ITK, and compiles it with the correct options to build with SimpleITK.

My recommendation to to verify that the core SimpleITK libraries are being built correctly and that the SimpleITK testing drivers get linked OK. If this is the case it tells us there is something not right with the way the linking is done for the wrapping and we need to closely look at that command line and the options CMake has.

HTH,
Brad

On Feb 14, 2017, at 9:24 PM, Longzhu Shen <lqshen10 at gmail.com<mailto:lqshen10 at gmail.com>> wrote:


Hi Brad and Matt,

Many thanks for the kind advice. I'm very new to ITK. Some of my
questions may be naive. I hope you could bear with me. I really hope to
get it working if I could. Thank you very much.

I checked out the freebsd port but I could not install it. (errors below)

Then I went back to the ITK src (I mistakenly thought simpleITK contains
ITK before) and tried to follow the manual to install it.

The cmake was fine for the most part but some errors did appear (
attached). Assuming those errors were not fatal, I
proceeded with make. The program stopped at the line below.

make[2]: don't know how to make ExternalData/Testing/Data/Input/MetaIO/Small\. Stop

It is the same error when I tried to compile from the ports.

Wondering whether I can seek some insight here or it is hopeless with
freebsd by this point. Thanks for advice.

sincerely,

Longzhu

<cmake_err.log>


Matt McCormick @ 2017-02-14 21:48 UTC:

Hi,

It is not likely that the errors are related to ITK_DYNAMIC_LOADING.

FreeBSD has a package for ITK, which gives its configuration:

https://www.freshports.org/science/InsightToolkit/
https://reviews.freebsd.org/diffusion/P/browse/head/science/InsightToolkit/Makefile

HTH,
Matt

On Tue, Feb 14, 2017 at 4:32 PM, Lowekamp, Bradley (NIH/NLM/LHC) [C]
<blowekamp at mail.nih.gov> wrote:
Hi,

Are we sure the first case was not close to mostly working? Did other
wrapped language link OK? did SimpleITK tests link OK? If ITK tests are
enable with ITK_DYNAMIC_LOADING:BOOL=0 do they compile and work? We need to
know if ITK is OK before moving to SimpleITK.

@Matt
I am not very familiar with CMAKE_DL_LIBS either [1]. I know Matt added the
ITK_DYNAMIC_LOADING CMake variable to ITK, so he may have insight into this
problem too. My guess is that CMAKE_DL_LIBS variable is not entered into the
cache but CMake provides a default value for platform. I expect you can
overrride it with command line values.

I hacked a patch to enable CMAKE_DL_LIBS to propgate down from the
Superbuild [2]. If you checkout that path you should be able to do a
supberbuild of -DCMAKE_DL_LIBS=“”. That may work, but I don’t know for sure.

HTH,
Brad

[1] https://cmake.org/cmake/help/v3.0/variable/CMAKE_DL_LIBS.html
[2] https://github.com/SimpleITK/SimpleITK/pull/104


On Feb 14, 2017, at 3:53 PM, Longzhu Shen <lqshen10 at gmail.com> wrote:

Hi Brad,

Many thanks for the advice.
I made an attempt to follow the first approach but it did not seem
work. Here is what I did and the errors I got.

-----------------------------------------------------
$ cmake ../SuperBuild -DITK_DYNAMIC_LOADING:BOOL=0


[ 80%] Building CXX object
Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/sitkPyCommand.cxx.o
[ 80%] Building CXX object
Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/SimpleITKPYTHON_wrap.cxx.o
[ 80%] Linking CXX executable bin/SimpleITKTclsh
/usr/bin/ld: cannot find -ldl
c++: error: linker command failed with exit code 1 (use -v to see
invocation)
--- Wrapping/Tcl/bin/SimpleITKTclsh ---
*** [Wrapping/Tcl/bin/SimpleITKTclsh] Error code 1
-----------------------------------------------------

I planned to try the 2nd approach. However, I could not find the
CMAKE_DL_LIBS easily. I checked the subfolder of Superbuild,
and SimpleITK-build/ITK-build. I did not find it in
Code/Common/src/CMakeLists.txt as well.

The only place I found "CMAKE_DL_LIBS" is in the file
CMake/sitkTargetLinkLibrariesWithDynamicLookup.cmake

279:        target_link_libraries(main \"${CMAKE_DL_LIBS}\")

I was wondering I may get further directions to modify CMAKE_DL_LIBS
variable. Many thanks.

sincerely,

Longzhu


Lowekamp @ 2017-02-14 15:36 UTC:

Hello Longzu,

You are using freebsd, that is new and exciting. I have not used that OS for
developing.

There are two things in the ITK/SimpleITK build that are related to this.

First, there is an option in ITK ( which I have not used ) call
ITK_DYNAMIC_LOADING. If you pass -DITK_DYNAMIC_LOADING:BOOL=0 to cmake for
the Superbuild, it should propagate to the ITK project and this feature will
be remove. This may solve your problem.

The second is CMake variable CMAKE_DL_LIBS. I believe it is the dl library
that is causing the problem [1]. Setting it to an empty string may also
remove it from the linking lines. Getting that to propagate to the ITK
project will not happen automatically and would need to be done manually in
the ITK build.

HTH,
Brad

[1]
https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/CMakeLists.txt#L142

________________________________________
From: Longzhu Shen [lqshen10 at gmail.com]
Sent: Tuesday, February 14, 2017 9:11 AM
To: community at itk.org
Subject: [ITK] compiling itk on freebsd, how to flag out ldl?

Hello,

I'm trying to compile simpleitk on my freebsd system.
The issue I encountered is ldl is not found.
After some searching, I found libdl is not needed on freebsd. It is
included in libc. Wondering how I can turn it off in the make file.
I did not find  ldl in the Makefile under Simpleitk-build.

I followed the instrutions from the link below.

https://chsasank.github.io/sitk-docs/building/unix.html#obtaining-source-code

Thanks.

Longzhu



--
Longzhu Shen, Ph.D.
Postdoc Research Associate
School of Forestry and Environmental Studies
Yale University
195 Prospect Street
New Haven, CT 06511




--
Longzhu Shen, Ph.D.
Postdoc Research Associate
School of Forestry and Environmental Studies
Yale University
195 Prospect Street
New Haven, CT 06511

_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170222/84940a60/attachment-0001.html>


More information about the Community mailing list