CIBC:Project:win64 development
Contents
Out of Date
This page is vaguely relevant, but at this point terribly out of date. The trunk is moving to CMake-ifying the third party stuff as well, so a lot of the third party stuff is wrong. Further, a lot of the scripts and edits mentioned here have since been committed and are no longer necessary.
-- Tfogal 18:44, 27 March 2009 (UTC)
Introduction to 64 Bit Windows Development
In this section we describe the current state of the 64 Bit Windows development of software developed within SCI.
Latest
Currently only 32 bit windows versions of SCIRun / Seg3D are available for download. However, we are in the process of porting some of the software to 64 bit. A binary will not be available until the SCIRun4 release.
Win64 build guide
- Checkout the SCIRun or Seg3D svn repository.
- The createCoreTclIndex.tcl file is not generated correctly; find where createDataflowTclIndex.tcl is created, and add this below it:
# TJF -- HACK! CONFIGURE_FILE( "${SCIRUN_CORE_SOURCE_DIR}/scripts/cmake_win32createTclIndex.in" "${SCIRUN_DATAFLOW_BINARY_DIR}/createCoreTclIndex.tcl" )
- Create a new directory, say perhaps C:\build\SCIRun (hereafter ${BUILD_ROOT})
- Hereafter, you'll need to be in a 64bit enabled command shell. Run cmd. Then run:
"c:\program files (x86)\microsoft visual studio 9.0\vc\vcvarsall.bat" amd64
If all is well, nmake should now be a valid command.
- In that new directory, use the following to create the nmake files (you'll probably need to modify some paths):
del CMakeCache.txt cmake ^ -G "NMake Makefiles" ^ -DSCIRUN_THIRDPARTY_DIR:PATH="C:/Users/admin/Documents/NCRR/cibc/SCIRun/thirdparty.win64" ^ -DPATH_TO_PSDK:PATH="C:/Program Files/Microsoft SDKs/Windows/v6.0a" ^ -DSCIRUN_ENABLE_64BIT:BOOL=ON ^ -DLOAD_PACKAGE:STRING="SCIRun,BioPSE,Teem,MatlabInterface" ^ -DBUILD_SHARED_LIBS:BOOL=ON ^ -DWITH_X11:BOOL=OFF ^ -DENABLE_DYNAMIC_COMPILATION:BOOL=OFF ^ -DBUILD_TYPE:STRING=Debug ^ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ^ -DBUILD_SEG3D:BOOL=OFF ^ -DBUILD_NAME:STRING="hostname_fixme-win64-nmake" ^ -DWITH_GDCM:BOOL=OFF ^ c:/Users/admin/Documents/NCRR/cibc/SCIRun/src
- Run nmake. Wait. A long time; nmake does not support parallel builds.
Issues & Pitfalls
Some issues you may run into, including plausible explanations and fixes.
Third party Software
A lot of software developed within SCI is dependent upon third party software and sometimes this software isn't Windows friendly. To enable us to port SCIRun to x86_64 processors we had to modify various third party source files and Visual Studio solution/project files. Unfortunately, these modifications have meant that it is a little more difficult to build the 64 Bit version of some third party libraries. Some issues to keep in mind, or changes which might be required, are:
- Ensure that the 64 bit extensions to Visual Studio 2008 are installed correctly. Otherwise, build or runtime errors occur, which are difficult to track down. This problem occurred when building tcl/tk and resulted in side-by-side errors when attempting to build SCIRun, which was caused by missing system libraries. The solution was to reinstall Visual Studio and choose the custom build then explicitly make sure that the 64 bit development tools are installed, which isn't set by default.
- Remove all visual studio 2003 & 2005 project + solution files. Furthermore, remove reference to any 32 bit build configuration in VS2008 files. It is unclear whether this is required, but it ensures you won't mix 32-bit and 64-bit code.
- Build the static .lib files separately from the dynamic .dll files. For example, use zlib's zlib.sln to build the the static library files rather than thirdparty.sln.
- Reconfigure Teem with CMake to ensure that it will build as 64 Bit and incorporating the new project files within the thirdparty Visual Studio solution.
- Download and modify a new version of png and libpng. The existing version wouldn't build without significant modifications and it was much easier to download a newer version and modify.
- Some of the Visual Studio project files contain absolute directory paths rather than relative paths. However, we are in the process of changing these absolute paths into relative paths to ensure that the new Windows thirdparty build environment is portable. Most of these issues have been solved, but some may still linger ...
- Modify teem project linker setting by adding z.lib and png.lib to the additional options panel under Linker > Command Line.
- If you use the Visual Studio IDE, it seems to arbitrarily switch back to building X86 code instead of x64 (equivalent to x86_64; MS doesn't respect the official name for some reason). The effect of this is a link error: fatal error LNK1112: module machine type 'X86' conflicts with target machine 'x64'. To fix this, change Properties | Linker | Advanced | Target Machine' is set to MachineX64 (/MACHINE:X64). Sometimes you may need to set Properties | Configuration Properties | C/C++ | Preprocessor to WIN64 from WIN32, as well.
- Using cmake to configure the build environment for any of the thirdparty components causes portability issues. For example, when configuring teem to build as a 64 Bit binary using Visual Studio all the library and header file directories generated within the project files are absolute paths. The result of this means that the teem Visual Studio project is tied to one specific machine. To overcome this issue we manually edited all the project files to replace the absolute paths with relative paths and . To avoid Visual Studio from reverting the changes made to the path we also removed all referenced cmake configurations in the same project files and deleted the cmake files in the bin directory and sub-directories. This still needs to be tested to ensure that it is truly portable, but if there is a problem the solution is to reconfigure teem using cmake, which isn't ideal but does work.
- If Visual Studio hasn't been installed correctly or has become corrupted, then strange runtime error can occur when executing wish8.4.exe in .../Debug64/bin (side-by-side error), which doesn't occur when executing the release build version of the same file. This problem is caused by missing debug runtime libraries or if only the visual studio 2008 redist package has been installed, which doesn't contain the runtime debug libraries. To solve this problem install or re-install Visual Studio 2008.
SCIRun
In this section we discuss some of the problems faced when trying to build a 64 Bit version of SCIRun for Windows.
- Strange linking errors can occur when the local copy of the SCIRun source has been updated and cmake isn't used to reconfigure the build environment. Although this shouldn't be necessary if no cmake files have been modified, to avoid possible linking errors it is advisable to reconfigure the build environment with cmake after every update.
- tcl/tk errors or warnings that occur during the build process in Visual Studio are typically the result of tcl/tk in thirdparty not being built correctly. To check this go to the thirdparty Debug64 or Release64 bin directory and execute wish8.4.exe. If an error message appears that mentions Side-by-Side error thirdparty (more specifically tcl/tk is corrupted) is corrupted and requires a clean rebuild.
- Strange build errors can occur when the build system is trying to link to the wrong version of a library. A typical error message mentions Side-by-Side and sxstrace. To solve these problems make sure that all the correct system libraries are installed, which might require Visual Studio to be reinstalled. This typically occurs when Visual Studio was installed without selecting the custom install option, because by default the 64 Bit components are not installed by default even when a complete install has been selected. The other common cause of this type of problem is a corrupt build of the thirdparty binaries and it is worth performing a clean build of thirdparty.