Build Vaa3D on Windows using mingw - Vaa3D/Vaa3D_Wiki GitHub Wiki

Following is the instruction to build 64-bit Vaa3D and its plugins on Windows using mingw8.1 and Qt 4.8.6

Prerequisites

  • Qt4.8.6 source ,choose qt-opensource-windows-x86-mingw482-4.8.6-1.exe to download.

  • mingw8.1, when installing, make sure the Settings choose: Version choose 8.1.0, Architecture x86_64,Threads win32, Exception siji, Build revision 0

  • Cmake(https://cmake.org/download/)

  • Common_lib, Put common_lib folder into v3d_external-\v3d_main\common_lib(supplementary material not replacement),bat file move to Path\v3d_external-\v3d_main

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

Modify Vaa3D Source code

1、Open terafly.pro file, change lib linkage winlib64 to mingw.

2、Open v3d_essential.pro file, change win32:LIBS... line to

win32:LIBS += -L../common_lib/mingw -lglew -lhdf5 -lszip -lzlib -lSDL2 -lteem  -lbz2 -lz -lopenvr_api -lwsock32

3、Comment out the 155 line of code in Path\v3d_external\v3d_main\common_lib\include\hdf5\H5public.h file.

//typedef long ssize_t;

4、Comment out the 72 line of code in Path\v3d_external\v3d_main\basic_c_fun\stackutil.h file.

//typedef V3DLONG BIT64_UNIT;

5、Change the code V3DLONG into long long in the 2091,2205,2206,2229,2230,2234 lines of Path\v3d_external\v3d_main\neuron_annotator\utility\ImageLoaderBasic.cpp file.

2091 long long uP=(long long)updatedCompressionBuffer;
2205 long long cStart=(long long)&compressionBuffer[0];
2206 long long cCurrent=(long long)compressionPosition;
2229 long long dStart=(long long)decompressionBuffer;
2230 long long tStart=(long long)targetData;
2234 long long sdStart=(long long)sourceData;

6、Comment out codes in Path\v3d_external\v3d_main\3drenderer\GLee2glew.c file.

Build Qt with mingw

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-g++

Then add this path to your PATH variable,

<your Qt path>\4.8.6\bin

so that your system knows where to find qmake.

Before building Qt,you need to change these codes below.

1、Change codes in api/qcoloroutput_p.h file.

ForegroundMask  = ((1 << ForegroundShift) - 1) << ForegroundShift,
BackgroundMask  = ((1 << BackgroundShift) - 1) << BackgroundShift

into

ForegroundMask = 0x1f << ForegroundShift   BackgroundMask = 0x7 << BackgroundShift

2、Change codes in /3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h

#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600))#include <type_traits>#endif

into

#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600))#include <tr1/type_traits>#endif

3、Comment code in Path\4.8.6\mkspecs\win32-g++\qmake.conf file below

QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98

Configure Qt with following line:

configure -debug-and-release -opensource -platform win32-g++

Once the configuration is complete,input make and then make install.

After finishing building Qt, remove comment on the code QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98.

mingw

After downloading mingw8.1, click on Environment Variable, Then add this path to your PATH variable

Path\mingw64\bin

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

TIFF

Should you wish to use more TIFF library version, please find this page to download and follow the instructions below. 4.0.4 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 mingw as the generator, and then click Generate. Copy all headers(.h) in tiff-x.x.x\libtiff to v3d_main\common_lib\include.

Configure and Build Vaa3D

  • Before configuring, 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\common_lib\mingw_dll.
  • Cd to the path v3d_external\v3d_main\jba\c++,input mingw32-make, this command creats a file "libv3dnewmat.a" in the v3d_main\jba\c++ folder, move it to common_lib\mingw\ to replace the original file.
  • Enter Path\v3d_external\v3d_main folder, cmd to execute mingw.bat.

Build plugins

create links between Vaa3D main body and plugins

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

Execute the following commands

cd <your Vaa3D path>\vaa3d_tools\released_plugins\build_plugindemo.bat

Run Vaa3D

Copy vaa3d_msvc.exe from <your Vaa3D path>\v3d_external\v3d_main\v3d\release to <your Vaa3D path>\v3d_external\bin.

Enjoy!