Farsight compilation note


This guide is based on http://www.farsight-toolkit.org/wiki/FARSIGHT_HowToBuild 

I added some notes based on my experience and share the problems I met with during compilation for Windows users doing similar work.


Step 1: Download

  • I am using Windows 10, VS 2010, Cmake 3.3, QT 4.8.6, GLUT 1.2(GL Files.zip), GIT 2.9.0, SVN 1.8.8.  Download and install if you have not these software yet.

  • Download FARSIGHT source code. Git Repository is located at: https://github.com/RoysamLab/Farsight-toolkit.git Save the folder to, for example H:\Farsight-toolkit-master\

Step 2: Compile

To solve the Dependency hell (really annoying), I strongly recommend green hand users to build farsight with Super build (http://www.farsight-toolkit.org/wiki/SuperBuild)

Open cmake-gui located in bin folder of Cmake. Select source code directory at Farsight source code location, in my occasion, that is H:/Farsight-toolkit-master/SuperBuild. Set build the binary directory to any location you want, in my occasion, H:/FarsightBuild. Press Configure, select "Visual Studio 10 2010" to compile. 

Make sure you have added VS VC bin (in my case, D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin) in system environment path, if not, Cmake cannot find the compiler. Make sure QT bin (D:\Qt\4.8.6\bin) in path as well, or cmake cannot identify whether you have installed QT.

If you compile with VS 2012 and later, there is an error of 

C1189: #error : The C++ > Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro.

It happens when compiling with legacy codes, 

See detail: https://mostlybuggy.wordpress.com/2012/12/18/getting-around-vs2012-c1189c4005-keyword-re-defined-in-macros/

For a quick solution, in CMake file, add the following: /D_ALLOW_KEYWORD_MACROS in the field CMAKE_CXX_FLAGS 


After pressing Configure button, change some build options. 

In "Build" cluster, select the modules you want, I unselected BUILD_TESTING and BUILD_FARSIGHT_TESTING to save time. 

In GLUT cluster, input location of GLUT, in my case, GLUT_INCLUDE_DIR is D:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include (I copied GLUT to VC include) GLUT_glut_LIBRARYD is D:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/lib/glut32.lib. 

In USE, select USE_SYSTEM_QT, which will save a lot of time if you have installed QT beforehand. 

In Ungrouped Entries, set ITK_BASE_DIR to the location you want to install ITK package, I use F:/ITKROOT


Make other necessary change if you want, then press Configure again, then Generate.

Farsight is made up of dozens of modules, many of them are not installed as default. The tracing system I want to build is one of them. Enter farsight source folder, and open CmakeLists.txt located in H:\Farsight-toolkit-master\Tracing, change this line: option( BUILD_TracingSystem "Build The Tracing System" ON ) if not, the tracing system will not be built.

In the build directory (H:/FarsightBuild), open ALL_BUILD.vcxproj, select Release version in solution configuration, and Build solution. 

The process will automatically download and compile each dependency first, then build farsight in the end. The process will last for a few hours.

In my case, there are a few errors in compilation.

Missing "fenv.h" -- I am not sure whether it is caused by imcompleteness of my vc version, I searched and copied such file from VS 2013 include dir (C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include) then it is solved.

error C3861: 'atoll': identifier not found -- Probably there is missing some files to make definition. When there is not atoll in system, I simply change it to #define atoLongLong atoi

Step 3: Develop

If there are no more error, the final exe files are in H:\FarsightBuild\Farsight\exe\Release

If you want to make change to the tracing system, enter H:\FarsightBuild\Farsight\Tracing\TheTracingSystem, and open TracingSystem.vcxproj. Note that TracingSystem is built depending on TraceCoreLibrary, so when modifying files in TraceCoreLibrary, build TraceCoreLibrary and then use new H:\FarsightBuild\Farsight\libs\Release\TraceCoreLibrary.lib to build tracing system.

Saving to vs .sln for convenience of loading two projects in one solution and make dependent rules. You do no need to compile the whole farsight again, only building tracing system in this solution if you have made any changes.


64 Bit version?

If you want to build 64 bit version, follow the steps below. Note that in 32 bit tracing system, the size of input image stack is limited, as there is only 2G memory for 32 bit version software in Windows. There are several memory eating filters after the input, so the input size is only limited to 12MB in my test. However, in 64 bit software, the memory limitation is not a problem.

As the tracing system uses Qt4, which is not officially supported in 64 bit, so 64 bit Qt library should be compiled by yourself from source code. See http://clatfd.cn/a/208 for details.

However, after trials and errors, the only working solution is following the Farsight official configuration, which is compiling Qt 4.7.2 and farsight code under VS 2008. I tried VS 2010, but release version program crashed in setup, the debug version can work only in very slow speed. Qt 4 is not stable in VS 2010. Update to Qt 5 or VS newer version.

VNK select int64 as default size_t, which will cause trouble in getting size of vnl vector. modify itk code to avoid problem.


Note that, in 3D image stack, the minimum slice number is 5, for the calculation of second derivative of gradient filter.


For independently building each modules and update dependencies to other versions:

ITK: remember to set on Module_ITKVtkGlue, Module_ITKReview in cmake to build these additional modules

Qt4->5 Cmake file is very different. In Qt5, modules are separated. Change to similar lines.

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
if(Qt5Widgets_FOUND)
   include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
endif(Qt5Widgets_FOUND)


if(QT_QMAKE_EXECUTABLE)
qt5_add_resources( GUI_RC_SRCS ${GUI_RCS} )
QT5_WRAP_CPP(GUI_MOC_SRCS TracingGUI.h TracingView.h ObjectSelection.h ParametersGroup.h SlidersGroup.h OpenSnakeTracer.h dialogs.h dialogs_landmark.h dialogs_montage.h ScatterView.h dialogs_scatter.h)
endif()

SET(TracingSystem_LIBRARIES
  ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES} TraceCoreLibrary ftkCommon ${TracingSysLibraries} TinyXML)

add cmake predix to save trouble in finding locations of each dependency

set (CMAKE_PREFIX_PATH "C:/Qt/Qt5.8.0/5.8/msvc2013_64")

Tracing system is only based on VTK, ITK, Qt (these are common dependencies), ftkCommon, ftkFeature, ftkImage, TinyXML, QHull (these are part of base dependency in Farsight-toolkit-master root directory), VXL (from FarsightBuild\ExternalProjects)

ITK depends on VTK, so build VTK first.

Load itkvnl.lib later than vnl lib from VXL, otherwise there will be redefinition problem.

After compilation, copy the correct release version of vtkGUISupportQt-7.1.dll in the same path of exe file, otherwise, the debug version of dll will be loaded. There will be an error "QWidget: must construct a QApplication before a QWidget" 


I have try to build it successfully using VS 2015 + windows10 + VTK 7.1.1 + ITK4.1 + Qt5.8

Changed cmake files a lot. It worked under following precedure, but still not combine everything together. You can have a try if you want play without border.

  1. Cmake superbuild to download and compile VXL

   2. Cmake farsightmaster to compile base dependency of farsight

   3. Download and compile newest version of VTK and ITK

   4. Download newest precompiled Qt (with correct VS version)

   5. Cmake tracing system to generate VS solution

   6. Edit or add anything wrong in include path or library path


If you want to use release and debug version at same time. Add both VTK bin folder to path, and 

If release version is started from Qt5cored.dll. Remember to copy vtkGUISupportQt-7.1.dll to exe folder

Have Fun!

Last Article Next article

Comment 评论



Share 分享

New Users 最新加入

  • hokurikustr

  • refrain

New comments 最新评论

test123: aasdas Details Apr 13 16:39
admin: Thanks! Details Apr 09 11:46
admin: Google map api Details Apr 09 11:46
lqj12: cooooooooool Details Apr 08 21:34
Yunhan Huang: 这个功能是如何实现的? Details Apr 08 13:23