Comments (23)
That is awesome! You are close!
Why I tried building on a RaspberryPi A1, I was running out of memory. With the default static libraries you likely are running out of memory.
You need to set the LD_LIBRARY_PATH to the build lib directory or install the SimpleITK "core" shared libraries.
You can consider SimpleITK to have two components. The core C++ libraries libSimpleITKBasicFilters*.so libSimpleITKCommone.so etc. And then there is the wrapping library for the specific languages i.e. _SimpleITK.so forPython. The wrapped package and library are handle in a language specific way for installation i.e. "python Python/Packaging/Python/setup.py install" With the normal static libraries this is sufficient.
The "core" SimpleITK shared libraries are installed via the traditional make install (in the SimpleITK-build sub-directory). The is done with the traditional "make install" and this installs in into the specified system location specified by CMAKE_INSTALL_PREFIX.
from simpleitk.
@blowekamp Would it be possible to add a RPI3 build for UBuntu/UBuntu-mate and place it on the official page? I will try the LD_LIBRARY_PATH also.
I have also built libraries and their Python wrappers for OpenCV and MMCore (from micromanager). Both are working. OpenCV also uses dynamic library building but when I load the cv2.xxxxx.so file from python, it loads up without any fuss! Can we refactor the CMake to account for this?
from simpleitk.
Also, there is a small compiler error that needed to be fixed. I am not sure where the source of the file is but this actually a generated file:
sitkMultiLabelSTAPLEImageFilter.cxx
Line # 242. I had to remove the "const" before FilterType *f.
However, I cannot freeze it as this file is a generated file. Is there some way this can be fixed?
from simpleitk.
I misses the other issue with shared libraries: all the ITK shared libraries need to be installed as well.
It is not likely that we will provide binaries for this platform. There is some work to hopefully improve the installation for the with shared libraries for python. However, just installing the dependencies or setting LD_LIBRARY_PATH is very little fuss.
Regarding the compilation error:
I need some more specifics about what version of SimpleITK you are building. Are you building the current 0.10rc1? Are you using the Superbuild with the provided version of ITK (or a system version of ITK?) Also please include the exact error message.
from simpleitk.
There is an ITK build for UBuntu-mate 16.04. I Installed it using sudo apt-get install
The error related to const cast ness ... I will generate that error on a second pi3, but if you have UBuntu, you can try and build it yourself. It will probably be faster also.
I am using the latest code from the trunk for SITK.
from simpleitk.
Yes, that sounds like a bug that was fixed in ITK. Do you know what version of ITK you are using? The version of ITK used with SimpleITK is fairly tightly coupled.
You may need to try the previous release of SimpleITK 0.9.1 to be compatible with the version of ITK you have. You should check the SuperBuild/Exeternal_ITK.cmake file to the needed version of ITK.
from simpleitk.
As I said,building SITK was not so much of an issue :) I fixed the compilation error by making that small change. But, if that is the case then maybe we need a wiki page to highlight this (else,a fix can be provided).
from simpleitk.
Suggestions and contribution on how to clarify that the Superbuild is the recommend way are welcomed: https://itk.org/Wiki/SimpleITK/GettingStarted#Building_using_SuperBuild
Regarding refactoring cmake. A major effort has gone on to refactor the SimpleITK "core" from the Wrapping projects. The goal is to aid the facilitate the "core" being packages and built separately from the many wrapped languages supported. The default static library configuration is suppose to be the "easy" way for "modern" computers.
from simpleitk.
This is what I get when building it using the Superbuild approach:
Scanning dependencies of target itkTestDriver
[ 99%] Building CXX object Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/itkTestDriver.cxx.o
[ 99%] Linking CXX executable ../../../../bin/itkTestDriver
/home/naths/Downloads/bin/SimpleITK/ITK-build/lib/libitkpng-4.10.so.1: undefined reference to `png_init_filter_functions_neon'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/build.make:120: recipe for target 'bin/itkTestDriver' failed
make[5]: *** [bin/itkTestDriver] Error 1
CMakeFiles/Makefile2:13185: recipe for target 'Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/all' failed
make[4]: *** [Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/ITK.dir/build.make:111: recipe for target 'ITK-prefix/src/ITK-stamp/ITK-build' failed
make[2]: *** [ITK-prefix/src/ITK-stamp/ITK-build] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ITK.dir/all' failed
make[1]: *** [CMakeFiles/ITK.dir/all] Error 2
Makefile:105: recipe for target 'all' failed
make: *** [all] Error 2
from simpleitk.
Thank you for trying the superbuild. This looks like something I can try to reproduce with a simular Ubuntu image. What version of Ubuntu? What version of clang? And what options did you configure?
from simpleitk.
Ubuntu Mate 16.04 for aPi3
clang3.8 (whatever came with sudo apt-get install)
The options were all default options with the following changes:
a.) Shared libraries
b.) No examples and no tests
c.) std and abi was libc++ (for clang)
I was able to solve that problem (somewhat). I had to hard code some stuff in pngpriv.h in ITK and then it built fine. But, even doing that led to another problem.
The code was compiling until it reached sitkLabelStatisticsImageFilter. The compilation just stopped!! (It said clang has crashed). I was running compilation on a single thread only.
SO far, the only combination that worked is:
a.) SITK the latest stuff from the trunk
b.) ITK 4.9 that comes with sudo apt-get install libinsighttoolkit4-dev
Of course, I was not able to load the _SimpleITK module in python. I will try and build it with SITK 0.09 and see what happens
from simpleitk.
One more bug here when building with 0.09
[ 2%] Building CXX object Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImage.cxx.o
In file included from /home/naths/Downloads/srcs/SimpleITK-0.9.0/Code/Common/src/sitkImage.cxx:18:
In file included from /home/naths/Downloads/srcs/SimpleITK-0.9.0/Code/Common/include/sitkImage.h:23:
In file included from /home/naths/Downloads/srcs/SimpleITK-0.9.0/Code/Common/include/sitkDetail.h:21:
In file included from /home/naths/Downloads/srcs/SimpleITK-0.9.0/Code/Common/include/sitkMemberFunctionFactoryBase.h:23:
/home/naths/Downloads/srcs/SimpleITK-0.9.0/Code/Common/include/nsstd/functional.h:26:10: fatal error:
'tr1/functional' file not found
#include <tr1/functional>
^
1 error generated.
Code/Common/src/CMakeFiles/SimpleITKCommon.dir/build.make:62: recipe for target 'Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImage.cxx.o' failed
make[2]: *** [Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImage.cxx.o] Error 1
CMakeFiles/Makefile2:224: recipe for target 'Code/Common/src/CMakeFiles/SimpleITKCommon.dir/all' failed
make[1]: *** [Code/Common/src/CMakeFiles/SimpleITKCommon.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
from simpleitk.
If I use SITK (trunk) + ITK (ubuntu build) and I disable building explicit instantiation, this is the error I get
Scanning dependencies of target SimpleITKCommon
[ 0%] Building CXX object Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImage.cxx.o
[ 0%] Building CXX object Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImageExplicit.cxx.o
In file included from /home/naths/Downloads/srcs/SimpleITK/Code/Common/src/sitkImageExplicit.cxx:33:
In file included from /home/naths/Downloads/srcs/SimpleITK/Code/Common/src/sitkImage.hxx:29:
In file included from /home/naths/Downloads/srcs/SimpleITK/Code/Common/src/sitkPimpleImageBase.hxx:29:
In file included from /usr/include/ITK-4.9/itkImageDuplicator.h:102:
In file included from /usr/include/ITK-4.9/itkImageDuplicator.hxx:22:
/usr/include/ITK-4.9/itkImageAlgorithm.h:26:12: fatal error: 'tr1/type_traits'
file not found
include <tr1/type_traits>
^
1 error generated.
Code/Common/src/CMakeFiles/SimpleITKCommon.dir/build.make:86: recipe for target 'Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImageExplicit.cxx.o' failed
make[2]: *** [Code/Common/src/CMakeFiles/SimpleITKCommon.dir/sitkImageExplicit.cxx.o] Error 1
CMakeFiles/Makefile2:148: recipe for target 'Code/Common/src/CMakeFiles/SimpleITKCommon.dir/all' failed
make[1]: *** [Code/Common/src/CMakeFiles/SimpleITKCommon.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
from simpleitk.
Please consider the following Dockerfile I use to reproduce a similar environment:
FROM ubuntu:14.04
RUN
apt-get update &&
apt-get -y upgrade &&
apt-get install -y build-essential &&
apt-get install -y emacs clang git cmake ninja
WORKDIR /tmp/
RUN
git clone https://github.com/SimpleITK/SimpleITK.git &&
cd SimpleITK &&
git checkout v0.9.1
RUN
mkdir bld &&
cd bld &&
cmake ../SimpleITK/SuperBuild
WORKDIR /tmp/bld
CMD ["bash"]
This currently just uses the system gcc, and it builds fine. Switching to clang causes the same error in ITK's limping.
There appears to be a bug using clang and ITK.
from simpleitk.
Regarding:
/usr/include/ITK-4.9/itkImageAlgorithm.h:26:12: fatal error: 'tr1/type_traits'
This is because you are mixing the System ITK with your compiled SimpleITK. The system ITK was compiled with gcc and lib stdc++, while you are compiling with clang and libc++.
ITK is a template library with many try_compiles can configurations specific for the compiler and C++ libraries used with it. You can't compile ITK with one set of setting (or compiler) and then use it with another.
I suggest using gcc to simplify things.
from simpleitk.
Yes @blowekamp, Indeed, I too figured out that ITK may have been compiled with gcc and I am trying to compile SITK with clang. However, SITK (from trunk, with clang) and system ITK is building fine! The only thing that made it work was the following:
I was suggested to use
"-std=c++11 -stdlib=libc++ -I/usr/include/libcxxabi" for CMAKE_CXX_FLAGS and
"-std=c++11 -stdlib=libc++ -lc++abi" for CMAKE_EXE_LINKER_FLAGS
When I added these lines, Simple ITK would not build.
However, when I disabled these lines from Simple ITK, it builds fine !!!
I can't use gcc as I have to reproduce this code on MacOSX also
from simpleitk.
So, I followed your advice and did the LD_LIBRARY_PATH approach. Now, the library is being loaded but I get the following error:
naths@naths-desktop:~/Downloads/bin/SimpleITK/Wrapping/Python$ python
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
import SimpleITK
Traceback (most recent call last):
File "", line 1, in
File "/home/naths/Downloads/bin/SimpleITK/Wrapping/Python/SimpleITK.py", line 28, in
_SimpleITK = swig_import_helper()
File "/home/naths/Downloads/bin/SimpleITK/Wrapping/Python/SimpleITK.py", line 24, in swig_import_helper
_mod = imp.load_module('_SimpleITK', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/naths/Downloads/bin/SimpleITK/lib/libSimpleITKCommon-0.10.so.1: undefined symbol: _ZNK3itk18MetaDataDictionary7GetKeysEv
from simpleitk.
Compiling ITK with a different compiler or C++ library than used to compile SimpleITK not supported.
from simpleitk.
I got it to work with the following steps (should anyone be interested):
a.) ITK -> from trunk
b.) SimpleITK -> from trunk
c.) Compiler clang 3.8 (as is native in ubuntu 16.04) - Do not add any additional CMAKE_CXX_FLAGS etc.
d.) Built ITK as static libraries
e.) Installed it via sudo make install - > There is a bug in the installation process. Two .h files from vnl are not installed vnl_export and vnl_algo_export.h. Had to manually copy them to the install folder
f.) Built Simple ITK (with shared libraries option on) and again using clang3.8 - Do not add any additional CMAKE_CXX_FLAGS etc. - Python wrapping on
g.) Had to change sitkMultiLabelSTAPLEImageFilter.cxx (Line # 242. I had to remove the "const" before FilterType *f.) - This is a generated file in SimpleITK
h.) Built it with a single thread only; Otherwise compilation process locks up
i.) Did a sudo make install for SimpleITK shared libraries
j.) Pointed this in LD_LIBRARY_PATH
k.) Started python (python 3.5 in this case) and imported SimpleITK
naths@naths-desktop:~/Downloads/bin/SimpleITK/Wrapping/Python$ python3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
import SimpleITK
quit()
and it works fine without any errors.
from simpleitk.
Thank you for sharing this detailed procedure, and your persistence to get SimpleITK to compile.
a) Please define "trunk"? git master or release? ( release recommend )
b) Please define "trunk"? git master or release? ( v0.10rc1 recommended )
c) good
d) This may cause some dynamic_cast failures. Did you run SimpleITK test suit?
e) For ITK shared libraries this is needed. You don't have to install ITK static. I suspect the missing header are only in ITK's development master branch and not release.
f) good
g) This should not be needed with correct matching ITK and SimpleITK versions.
h) I wonder if this is a raspberry issue or a ITK static library one.
i) good
j) If SimpleITK's core libraries are installed into the system LD_LIBRARY_PATH should not be needed
k) you may need to run cd SimpleITK-build/Wrapping/Python; python setup.py install
Working on a docker script to follow this recommend process...
from simpleitk.
Bradley, all checkouts were "master" checkouts. I forgot to add one more thing. itkTestDriver was failing during the build process. Apparently, there is an undefined symbol in pngpriv.h that was causing this. I had to disable ARM optimizations in that file. However, there can be an elegant way of doing this from CMake but I did not bother to do that as that would involve wholesale changes.
Regarding point g.) I was having the same problems with the ubuntu supplied ITK and the one that I built. You can check it out and see if it works. Again, j.) is "user preferences" so I leave that out of the build !
Regarding point h.) I think it may be a RPI3 issue. So I again would not mess with that unless someone else can come up with a better solution.
from simpleitk.
The pngpriv.h issue and the vnl header issue are an upstream ITK issue. Contributions to ITK ( an SimpleITK ) are welcomed!
g) I with the branches I used in Docker I didn't need this fix
j) When the ITK/SimpleITK libraries are installed in standard system locations and lddconfig is run LD_LIBRARY_PATH is not needed. If you are running from a development location this variable may need to be set.
h) My Intel x86_64 tests are passing so it is likely a RPI3 related issue. Or there may be a related issue with ITK being static, and duplication of global variables.
HTH
== DockerFile ==
FROM ubuntu:14.04
RUN
apt-get update &&
apt-get -y upgrade &&
apt-get install -y build-essential clang git curl swig python-dev
RUN
curl -O https://cmake.org/files/v3.6/cmake-3.6.0-Linux-x86_64.sh &&
umask 022 && echo "y\n" | bash cmake-3.6.0-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir
WORKDIR /tmp/
RUN
git clone https://itk.org/ITK.git &&
cd ITK &&
git checkout release &&
mkdir bld
RUN
cd ITK/bld &&
CC=clang CXX=clang++ cmake
-DBUILD_SHARED_LIBS:BOOL=ON
-DUSE_COMPILER_HIDDEN_VISIBILITY:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DModule_ITKReview:BOOL=ON
.. &&
make -j $(nproc) install &&
ldconfig
RUN
git clone https://itk.org/SimpleITK.git &&
cd SimpleITK &&
git checkout v0.10rc1 &&
mkdir bld
RUN
cd SimpleITK/bld &&
CC=clang CXX=clang++ cmake
-DBUILD_SHARED_LIBS:BOOL=ON
-DWRAP_LUA:BOOL=OFF
-DWRAP_PYTHON:BOOL=ON
-DUSE_SYSTEM_SWIG:BOOL=ON
-DUSE_SYSTEM_ITK:BOOL=ON
../SuperBuild &&
make -j $(nproc)
RUN
cd SimpleITK/bld/SimpleITK-build &&
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local . &&
make install &&
ldconfig
RUN
cd SimpleITK/bld/SimpleITK-build/Wrapping/Python &&
python setup.py install
CMD ["bash"]
from simpleitk.
Bradley, I am sure building on Linux will be a breeze. However, this was for a Pi3. However, that being said if others can replicate this for a Pi and maybe suggest improvements, then, can you please add this to the main page? It may help others also doing this
from simpleitk.
Related Issues (20)
- Merge 2D images into nifti files HOT 6
- Reading images in Google Cloud HOT 2
- merge multi nii files to one nii file HOT 1
- Request that SimpleITK support TPS (Thin Plate Spline) transform
- Simple Elastix is much slower now compared to before HOT 11
- Read an image series (JPEG or PNG) and write it as a single niip.gz file
- Use only corresponding points based transformation HOT 4
- SimpleITK cannot seem to read nrrd or nhdr files on linux HOT 2
- Unable to perform simple image registration HOT 4
- Support for Android ? HOT 4
- [question] how to replicate a ridig registration done with ANTs / niftyreg HOT 4
- simpleITK has no attribute DICOMOrient HOT 6
- Can't save 3d numpy array as a series of 2d dicom scans HOT 1
- Clarify Windows build docs for Superbuild subdirectory.
- fail to install simpleITK due to gdc HOT 1
- fresh conda env with ImportError: nomodule named '_SimpleITK' on Windows 11 HOT 2
- SIEMENS .ima MagnetomVision files HOT 3
- Release wheels for SimpleITK with Elastix for Ubuntu HOT 1
- Compilation on M1 Error: HOT 1
- CMake hangs on M1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleitk.