Build Vaa3D on Windows with qmake using VS2013 and Qt4.8.6 - Vaa3D/Vaa3D_Wiki GitHub Wiki

Following is the instruction to build 64-bit Vaa3D and its plugins on Windows using Visual Studio 2013 with qmake. Note that Qt4.8.6 is the earliest version fully compatible with VS2013, hence this article is based upon this requirement.

Prerequisites

  • Microsoft Visual Studio 2013 - Free community version can be downloaded here.
  • Qt4.8.6 source - After download, rename the folder that is unzipped from the package to '4.8.6'.
  • Boost C++ Libraries - After download, just double click the executable to install the libraries.
  • Git - This is the bash you need to communicate with Vaa3D repository.
  • CMake(https://cmake.org/download/) - A cross platform makefile program that allows you to generate project files for your compiler. Today most open source programs or libraries come with CMake script (CMakeList.txt) in their packages. If it does not provide build executable, like boost's bjam, one will need to use CMake to enable the process.

Acquire Vaa3D Source

Open Git Bash and navigate to the folder where you wish to build Vaa3D. Then use the following 2 lines to download Vaa3D source and its submodule:

git clone --recursive https://github.com/Vaa3D/v3d_external.git
git clone https://github.com/Vaa3D/vaa3d_tools.git

Create links between Vaa3D main body and plugins

Plug-in sources are located in vaa3d_tools folder. We create several links between Vaa3D main body and vaa3d_tools folder to make path specifying easier in project files. To do this, one needs to create directory links with the following lines in VS2013 x64 Native Tools Command Prompt:

cd <your Vaa3D path>\vaa3d_tools
mklink /j  v3d_main ..\v3d_external\v3d_main
mklink /j  bin ..\v3d_external\bin
cd ..\v3d_external
mklink /j  released_plugins_more  ..\vaa3d_tools\released_plugins

Build Qt and Essentials

Qt

Before Qt can be built, couple of system paths and environment variable have to be specified. In control panel > system, go to Advanced system settings and click on Environment Variable. Create 2 new variables with the values as shown below:

QTDIR=<your Qt path>\4.8.6
QMAKESPEC=win32-msvc2013

Then add this path to your PATH variable,

<your Qt path>\4.8.6\bin

so that your system knows where to find qmake.

Open VS2013 x64 Native Tools Command Prompt and navigate to <your Qt path>\4.8.6. Configure Qt with the following line:

configure -debug-and-release -opensource -platform win32-msvc2013

Once the configuration is complete, input nmake to initiate the build process. If you have jom in your Qt path, it can be used to speed up building Qt. In such case, run .\jom.exe -j N instead of nmake, where N refers to the number of CPU cores you wish to utilize, the larger the faster. jom is a clone of nmake that supports multiple independent commands in parallel. It can be downloaded from here.

After the process is finished, input qmake -v to see if your VS2013 recognizes qmake. This command should return the version number of qmake. If not, an error message saying "qmake is not recognized internal or external command" will show. It can happen when you play with different versions of Qt on the same machine. Navigate to C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64 and run vcvars64.bat to force VS2013 to have all environment variables settled. It is necessary to have VS2013 recognize qmake for that Vaa3D and all plugins are created in Qt project format, and VS2013 needs qmake to generate proper visual studio project files so that they can be compiled.

Boost

By default, the boost libraries will be installed in the directory of C:\local\boost_1_61_0. Create another environment variable for your system:

BOOST_PATH=C:\local\boost_1_61_0

Note, if you chose elsewhere when installing the boost libraries, your BOOST_PATH would have to be specified accordingly.

If you encountered the error "can not find boost", you can add the boost header files to the include directory of common_lib, and you can create links.

cd <your Vaa3D path>\v3d_external\v3d_main\common_lib\include
mklink /j boost <your boost path>

TIFF

Should you wish to use more TIFF library version, please find this page to download and follow the instructions (recommond Tiff version: 4.1.0) and above have all been tested and work fine with Vaa3D.

First,decompress the tiff package to PATH\vaa3d_tools\v3d_main\common_lib\src_packages\.Then open CMake gui, put the path of tiff-x.x.x folder(TIFF library you decompress) in both 'Where is the source code:' and the same in 'Where to build the binaries:' fields. Click Configure, select Visual Studio 12 2013 Win64 as the generator, and then click Generate. In the same folder, ALL_BUILD.vcxproj will be generated. Open it with VS2013, make sure it's configured Release and x64 as the platform, then build the solution. After build, copy all headers(.h) in tiff-x.x.x\libtiff to v3d_main\common_lib\include.

Libraries for Neuron Assembler module (Optional)

Neuron Assembler (preciously called Fragment Tracer) is an additional feature for neuron tracing with object-based approach. To enable this, 2 libraries need to be built beforehand - NeuronStructNavigator.lib and v3d_imgManager.lib. Simply go to PATH\vaa3d_tools\hackathon\MK\NeuronStructNavigator, open NeuronStructNavigator.vcxproj in VS2013 and build. Similarly, go to PATH\vaa3d_tools\hackathon\MK\v3d_imgManagerMK, open v3d_imgManagerMK.vcxproj in VS2013 and build.

Configure and Build Vaa3D

  • Enter "PATH\v3d_external\v3d_main\v3d" folder.
  • Run qmake -tp vc vaa3d_msvc.pro. This command creates a MS Visual Studio 2013 project file " vaa3d_msvc.vcxproj" in "v3d_main\v3d" folder.
  • Use MS Visual Studio 2013 to open vaa3d_msvc.vcxproj.
  • Under Build -> Configuration Manager:
    • Choose building in "Release" mode in MS Visual Studio 2013.

    • Choose building in "x64" (for 64bit building) mode in vaa3d_msvc Property Pages, or just select from the building platform located in the toolbar. If “x64” mode does not exist, create one by choosing 'New' and then copying the previous configuration settings.

    • Now hit build button to start building process.

Build plugins

Execute the following commands in the Visual Studio command prompt:

cd <your Vaa3D path>\v3d_external\released_plugins_more
build_plugindemo_msvc.bat
cd <your Vaa3D path>\vaa3d_tools\released_plugins
build_plugindemo_msvc.bat

Run Vaa3D

  • Copy vaa3d_msvc.exe from <your Vaa3D path>\v3d_external\v3d_main\v3d\release to <your Vaa3D path>\v3d_external\bin.
  • Some dynamic Qt libraries are required to run Vaa3D. Copy QtCore4.dll, QtGui4.dll, QtNetwork4.dll, QtOpenGL4.dll and QtXml4.dll from <your Qt path>\4.8.6\bin to <your Vaa3D path>\v3d_external\bin.
  • you should also copy glew32.dll,openvr_api.dll and SDL2.dll from <your Vaa3D path>\v3d_external\v3d_main\v3d\release to <your Vaa3D path>\v3d_external\bin.
  • Enjoy!