Build Vaa3D on Mac OS - Vaa3D/Vaa3D_Wiki GitHub Wiki

Build From Source

PREREQUISITES: Qt and C++ compilier

You should have both Qt and C++ compiler ready on your system.

You can get Qt from

http://qt-project.org/downloads

Supported Qt versions

Note, some of the newer versions of Qt (e.g. Qt 4.8.7 +) might not be compatible with some of operating systems (e.g. Mac 10.10). To avoid these problems, you can download a relatively stable Qt version, e.g. 4.8.6, from the following link.

https://download.qt.io/archive/qt/

In case you cannot compile the required Qt library with the latest Command Line Tools (XCode 6.0 or higher), you can grab a pre-compiled binary library, which has been tested for most common OS platforms using the qmake and shell script (when building using CMake, qt 4.7.1 may not work with some of the default c++ compilers, for example Mac OS X 10.9.5 and its LLVM 3.5) , as follows:


  1. (Mac only ) Download the precompiled Qt 4.7.1 library from this link

2. Unpack it to /usr/local/Trolltech such that your qmake path is /usr/local/Trolltech/Qt-4.7.1/bin/qmake.

3. Permanently add your qmake path to the system path:
  • open the Terminal and go to your home directory
  • create (or edit) the .bash_profile file with a command line editor (e.g. nano)
      nano .bash_profile
  • add the line
      export PATH="/usr/local/Trolltech/Qt-4.7.1/bin:$PATH"
which declares the new location /usr/local/Trolltech/Qt-4.7.1/bin as well as the original path declared as $PATH.
  • save the file in nano by clicking control+o and confirming the name of the file is .bash_profile by hitting return. And the control+x to exit nano
  • relaunch the Terminal and check that your qmake works by typing
      qmake --version
which should produce
 QMake version 2.01a
Using Qt version 4.7.1 in /usr/local/Trolltech/Qt-4.7.1/lib

Note:

For those who have installed Qtlib using Qt Installer directly, and at the same time also have other Qt versions installed, the computer might be messed up in a way it might not be clear which Qt library would be linked during building. To resolve the issue, one can revise the corresponding building script (build.macx for Mac and build.linux for Linux) by adding the following statements at the beginning (let's use Qt 4.7.1 as an example)

QT4=<QT_4.7.1_PATH>
PATH=$QT4/bin:$PATH
QMAKESPEC=$QT4/mkspecs/<spec>

Here <QT_4.7.1_PATH> is the placeholder for the directory where Qt 4.7.1 is installed and <spec> is the placeholder for specification. For example, <spec> can be macx-g++ for Mac OS and linux-g++ for Linux, depending on what C++ complier you want to use.




Download Source Code and Build

You need to check out source code from two github code repositories, one for main Vaa3D code and one for some released plugins. You can following the instructions for both Vaa3D program and its default plugins.

Vaa3D Source Download

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

Setup Symbolic Directory links for Building Plugins

The vaa3d_tools contains the majority of the plugins. The plugin sources are separated from the trunk, so in order to build the plugins in vaa3d_tools into the main program using QMake (If you are using CMake, you don't need to set up the folder cross linkes, you could configure the install directories during CMake configuration time. However, many of the existing plugins can only be built with QMake right now.) The following folder setting needs to be done:


cd vaa3d_tools
ln -s ../v3d_external/v3d_main v3d_main
ln -s ../v3d_external/bin bin
cd ../v3d_external
ln -s ../vaa3d_tools/released_plugins released_plugins_more

Build Instructions



# for 64 bit builds, use -m ./build.macx -m -j4 <-B>
# for 32 bit builds, use -n ./build.macx -n -j4 <-B>

The last few lines create symbolic links for necessary header files and output plugins.

You may replace the "-j4" using "-j8", "-j2", or "-j16", depending on how many CPU cores your have on your machine. Note that the "make" command on some systems (e.g. Ubuntu) may not recognize the "-j" parameter. In such as case, you can just run "build.macx" without that parameter.

Other Issues

For Qt4.7.1 to support c++11

(A) Modify the following 3 files within Qt-4.7.1 to support c++11.


  1. Qt-4.7.1/include/QtCore/qobjectdefs.h change the LINE 217 to the following:

#if __cplusplus >= 201103L || (__cplusplus < 200000 && __cplusplus > 199711L)
# define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__)
#else
# define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__)
#endif
  1. Qt-4.7.1/include/QtCore/qplugin.h change the LINE 112 to the following:

#if __cplusplus >= 201103L || (__cplusplus < 200000 && __cplusplus > 199711L)
#define Q_PLUGIN_VERIFICATION_DATA \
static const char qt_plugin_verification_data[] = \
"pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \
"version=" QT_VERSION_STR "\n" \
"debug=" QPLUGIN_DEBUG_STR "\n" \
"buildkey=" QT_BUILD_KEY;
#else
#  define Q_PLUGIN_VERIFICATION_DATA \ 
static const char qt_plugin_verification_data[] = \
"pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \
"version="QT_VERSION_STR"\n" \
"debug="QPLUGIN_DEBUG_STR"\n" \
"buildkey="QT_BUILD_KEY;
#endif
  1. Qt-4.7.1/mkspecs/common/mac-g++.conf

replace all “-mmacosx-version-min=10.5” with “-mmacosx-version-min=10.7”

(B) uncomment the following lines in v3d64.pro:


#QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -Wno-c++11-narrowing
#LIBS += -lc++
⚠️ **GitHub.com Fallback** ⚠️