Build Windows

From emergent
Jump to: navigation, search
Emergent Logo
Installing and Building Emergent
  • Build from source (expert)

This is info for building version 8.0 and higher (until superseded!) under Windows Visual Studio 2015. Also Packaging Windows which has information on building plugins which has not been done/tested with emergent version 8.0

Directory Structure

The build process and standard scripts assume a certain directory structure, with relevant environment variables as noted (all caps):

  • C:\src -- all source code goes here, including emergent, and if you end up rebuilding libs from source
  • C:\src\emergent -- this is where you should use svn to checkout emergent source into
  • C:\Qt\Qt<version>\<vers>\msvc2015_64 = QTDIR -- Qt install dir, where <version>=5.6.1 and <vers>=5.6 for example.
  • C:\Coin\4.0.0.a = COINDIR -- location of Coin 3D and Quarter libs / includes
  • C:\Subversion = EMER_SVN_LIBS_DIR -- subversion -- exe should be right in Subversion dir, not in bin -- apparently bin is more for .dll's in windows..
  • C:\EmerMiscLibs = EMER_MISC_LIBS_DIR -- the ODE, GSL, and zlib libs all go here.. NOTE: this used to be called 3rdParty -- we figured it was time to come up with a clearer name..
  • C:\Program Files\Emergent -- this is where emergent is installed by default with a "make install"

Download Build tools

Download prerequisite libraries

We are supporting both Qt 5.6.1 and Qt 5.3.2 based builds on windows, because the older 5.3.2 version is the only thing that works for older versions of windows, and runs in VirtualBox virtual machines. The coin distribution contains two branches for quarter made from these two Qt versions, and there are two different build scripts, etc.

Reference Information on Prerequisite Libraries

These are all the libraries that emergent depends upon -- on most Build procedures, these libraries are available as pre-compiled, easy-to-use packages of one form or another. This information is just for general reference and in case you want to update or otherwise do something special with a particular library.

Current versions of each relevant package are always available on our ftp site:

ftp://grey.colorado.edu/pub/emergent or https://grey.colorado.edu/emergent_ftp/

The prerequisites are generally the same across operating systems but always check the operating system specific build instructions for version info.

Package Cur Version Main URL Download URL Docs URL
Qt (gui and OS api) 5.6.1 (LTS) (also works with old versions, back to 4.8 or so) https://www.qt.io/ https://www1.qt.io/offline-installers/ http://doc.qt.io/qt-5/reference-overview.html
Coin & Quarter (3D scenegraph & Qt api) 3.1.3 We have our own patched version that is required: Coin3d Coin3d
ODE (Physics sim) 0.14 http://ode.org/ https://bitbucket.org/odedevs/ode/ http://opende.sourceforge.net/wiki/index.php/Manual
GSL (math library) 1.13 http://www.gnu.org/software/gsl/ ftp://ftp.gnu.org/gnu/gsl/ http://www.gnu.org/software/gsl/manual/html_node/
cmake (build system) 3.6.1 (NOTE: avoid anything before 2.8.4) http://www.cmake.org/ https://cmake.org/download/ https://cmake.org/documentation/
subversion (required from v6.2.0) 1.9.4 http://subversion.apache.org http://subversion.apache.org/packages.html (use WANdisco, full package for mac, installs in /opt/subversion)
libsndfile (sound file load / save -- optional, needed for auditory) 1.0.26 http://www.mega-nerd.com/libsndfile/ http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.26.tar.gz n/a

Checkout emergent source code

The vsinit15.bat build script

NOTE - We also suggest you install https://www.cygwin.com (do not install the 64 bit version -- just the older 32 bit works) -- this is a very handy way to get things like scp and rsync for copying files to a linux server, and providing a more comfortable shell environment for linux / mac command-line users.

This script lives in win_build\vs15init.bat (or vs15init_qt53.bat) and the version there should always be used over what you see here! But the general structure is the same. Basically it defines a bunch of variables matching the structure shown above, and defines a bunch of aliases using the doskey command, which make it easy to call cmake with all the right configuration args, and even run the visual studio ide on a "solution" file generated by cmake configure. See the top of the script for instructions on how to make it runnable with one click.

Be sure to always remember to do configure and making in a build subdir!!

Essential to run VS from the vside command line and NOT directly from the gui!!

e.g., after you run this script, you need to do something like this:

mkdir build
cd build
configure
jom -j4

This will build the entire thing, resulting in an executable in bin/emergent.exe

To install into C:\Program Files\Emergent then do:

jom install

If you want a Visual Studio project for a debug build you need to run configure_ide_dbg and do it in a different directory, for example

mkdir build_dbg
cd build_dbg
configure_ide_dbg
vside

The last command opens the project in Visual Studio 2015 -- always use that command to start VS so that the proper environment variables are set. The ALL_BUILD solution, Debug mode should be selected for building. To run, you need to go down the "solution explorer" list and select emergent, and select Debug / start debugging.


:: This is a .BAT script for configuring the emergent build process under VS tools

:: to make this runnable as a desktop shortcut, first create a shortcut to cmd.exe on the desktop
:: (open the windows file explorer, go to C:\Windows\System32, search for cmd.exe, right click, create shortcut)
:: then edit the shortcut's properties on the desktop, and in the box where it says Target, enter:
:: C:\Windows\System32\cmd.exe /K C:\src\emergent\win_build\vs15init.bat
:: you can also change the name in General tab to something like emergent vs15init

:: all the init for command-line operation of VS
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

:: doskey = aliases!

:: for unix shell users
doskey ls=dir $*
doskey cp=copy $*
doskey rm=del $*
doskey rmr=rmdir /s $*
doskey mv=move $*

set BITS=64
set BUILD_TYPE=Release
set SRC_DIR=C:\src\emergent
set ARCH=64

set QTDIR=C:\Qt\Qt5.6.1\5.6\msvc2015_64
set EMER_MISC_LIBS_DIR=C:\EmerMiscLibs
set COINDIR=C:\Coin\4.0.0a
set EMER_SVN_LIBS_DIR=C:\Subversion
set ZLIB_ROOT=C:\EmerMiscLibs\zlib-win64-msvs2013

:: this is the key configure command -- you can now type it just by typing "configure"
doskey configure=cmake %SRC_DIR% -G "NMake Makefiles JOM" -Wno-dev -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DQT_USE_5=ON -DQTDIR=%QTDIR% -DCMAKE_SHARED_LINKER_FLAGS="/machine:X%ARCH%" -DCMAKE_MODULE_LINKER_FLAGS="/machine:X%ARCH%" -DCMAKE_EXE_LINKER_FLAGS="/machine:X%ARCH%" -DZLIB_ROOT=%ZLIB_ROOT%

:: Following is for ide usage -- default to Debug mode for ide b/c that is what it is useful for:

:: The following environment variable must be set from the command line to force the IDE to use the x64 native compiler
set PreferredToolArchitecture=x64

:: run this in a build_ide_dbg subdirectory to configure for ide
doskey configure_ide_dbg=cmake %SRC_DIR% -G "Visual Studio 14 Win64" -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DQT_USE_5=ON -DQTDIR=%QTDIR% -DCMAKE_SHARED_LINKER_FLAGS="/machine:X%ARCH%" -DCMAKE_MODULE_LINKER_FLAGS="/machine:X%ARCH%" -DCMAKE_EXE_LINKER_FLAGS="/machine:X%ARCH%" -DZLIB_ROOT=%ZLIB_ROOT%

:: run this in any build directory that cmake generated, e.g., the one from configure_ide_dbg above
:: ALWAYS open the solution from the command line, to ensure the PreferredToolArchitecture variable is set correctly.
doskey vside="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" Emergent.sln

:: set the global path to include all our stuff -- this path is also used to find .dll's so it is like LD_LIBRARY_PATH
path C:\Program Files (x86)\CMake\bin;C:\Subversion;C:\jom_1_1_1;C:\cygwin\bin;%QTDIR%\bin;%COINDIR%\bin;%EMER_MISC_LIBS_DIR%\bin;%EMER_SVN_LIBS_DIR%;%EMER_SVN_LIBS_DIR%\bin;C:\Windows\system32;%PATH%

cd %SRC_DIR%

Building Package

  • You must start command prompt with administrator privileges -- if you aren't already in an administrator window right click on start menu, and choose Command Prompt (Admin)
  • jom install -- key to install prior to building packages -- the installer builds packages from the *installed* version of the software
  • It seems that the NSIS package software uses CPACK_NSIS_INSTALL_ROOT rather than CPACK_INSTALL_PREFIX to set the default install location. So you need to make a small edit to get the package installed in the correct directory.
    • Edit CPackConfig.cmake and change CPACK_PACKAGE_INSTALL_DIRECTORY to be "Program Files\\Emergent" (double slash is correct) jom package

Building Coin and Quarter

When we move to a newer version of Qt (or there is a change to the coin or quarter code) the quarter code needs to be rebuilt. -- the coin code only needs to be rebuilt if the coin code changes or we move to a new compiler

As of 8.2.0 quarter is built into the emergent source.

Install Cygwin, Required for Building!

  • Download and install cygwin (NOT cygwin64) there are some optional tools that need to be added to the basic cygwin install:
  • Devel/automake, autobuild, autoconf, make, makedepend, binutils, Net/rsync
  • If something isn't found you can go back to cygwin setup and search for the missing tool and add it
  • Open a command prompt and set up the tools by executing this line

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

  • Then activate Cygwin shell -- must be cygwin not cygwin64 - otherwise the VC++ compiler isn't found (saying it again!)

C:\cygwin\Cygwin.bat

  • VERY IMPORTANT: the link.exe command will likely be the one from cygwin and not VS at this point, and that is bad -- if you get error messages like "link: extra operand /INCREMENTAL:NO" or similar, that is an indication of this problem.
cd /usr/bin
mv link.exe link_cygwin.exe

Build Coin

  • Start by downloading the coin and quarter code into C:\src\coin

svn checkout https://grey.colorado.edu/svn/coin3d/coin/trunk C:\src\coin

  • now cd to the build directory

cd /cygdrive/c/src/coin/build

  • run the configure process ("ignore" - need to ignore carriage returns added by windows)
    • after configuring the script will change to either the release or debug directory and reset the path

bash -x -o igncr vs15_coin_build.sh <release or debug>

  • compile - do not use the "-j" option - problems with multiple processes writing to the same .pdb file
  • BUT FIRST - make sure that path starts with Visual Studio 14.0 - If you see the path start with /usr/local/bin you need to reset the path - look at the end of the script for the set path line and paste that into your command window and execute before running make to ensure that you get the 64 bit linker

make

Oh, yeah, you need to move the dlls, pdbs, libs, etc into C:/Coin/4.0.0a/bin and /lib

Build Quarter

IMPORTANT: As of 8.2.0 Quarter is built into emergent and this does not need to be rebuilt ever again! :)

svn checkout https://grey.colorado.edu/svn/coin3d/quarter/trunk C:\src\quarter

  • now cd to the build directory

cd /cygdrive/c/src/quarter/build

  • run the configure process ("ignore" - need to ignore carriage returns added by windows)

bash -x -o igncr vs15_quarter_build.sh <release or debug>

  • there is a _qt53 version for building against Qt 5.3.2 which is the last version that works with older versions of windows (and virtual machines), due to opengl driver issues
  • if the script didn't get you into the release or debug directory cd to the appropriate one
    • If and only if you are building release versions you need to edit config.status
    • search for -lcoin4d and change it to -lcoin4
  • compile - do not use the "-j" option - problems with multiple processes writing to the same .pdb file

make

  • The compiled files are in src/Quarter -- need to move them to the final install location:
  • cp Quarter1.dll /cygdrive/c/Coin/4.0.0a/bin -- etc -- pdb goes in bin, .lib and .exp go into lib

Building Miscellaneous Dependencies

Build ODE

Emergent 8.0.0 was built with Open Dynamics Engine source code 0.14 (available here - https://grey.colorado.edu/emergent_ftp/ode-0.14am.tar.gz and built based on the instructions at http://ode-wiki.org/wiki/index.php?title=Manual:_Install_and_Use

  • cd into ode-0.14/build and run premake4.exe

premake4 --only-single --platform=x64 --with-libccd --with-builtin-threading-impl vs2010

(vs2010 is the most recent toolset that worked with premake4 -- vs2015 will automatically update the .sln file appropriately, and the builtin threading impl appears to be essential to getting it to work -- why this is not the default on windows is unclear..)

  • You now have a directory build/vs2010
  • Open ode.sln in Visual Studio 2015 and let it upgrade the solution/projects
  • You need to build 2 configurations, bothl 64 bit
    • ReleaseDLL
    • DebugDLL
  • the generated files will be in lib under main dir
  • The dll's and pdb's go into EmerMiscLibs/bin and the lib's and exp's into EmerMiscLibs/lib
  • copy ode-0.14/include/ode into EmerMiscLibs/include (drawstuff is not needed)

Build ZLIB

Emergent 8.0.0 was build with zlib 1.2.8 using VS2015 from the vc11 project in the contrib/vstudio/vc11 directory (available here - https://grey.colorado.edu/emergent_ftp/zlib-1.2.8.zip)

  • Open contrib/vstudio/vc11_updated_to_VC14/zlibvc.sln in Visual Studio 2015 and let it upgrade the solution/projects -- or you need to do Project/Retarget Solution if it doesn't prompt you to upgrade it (if you get our zlib zip?).
  • Need to edit contrib/vstudio/vc10/zlibvc.def and change 1.2.8 to 1.2 (only major and minor) (this was already done!?)
  • and per http://stackoverflow.com/questions/17102770/using-the-windows-8-sdk-to-compile-for-windows-7 need to edit contrip/minizip/iowin32.c:
#if false   /* default to always using win7 api for max compatibility */
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define IOWIN32_USING_WINRT_API 1
#endif
#endif
#endif
  • Best to build both release and debug versions of the lib and dll - all 64 bit (configuration will say x64)
  • the generated files will be in vc11_updated_to_VC14/x64/ZlibDllRelease
  • Before moving the lib and exp files into EmerMiscLibs/lib rename them by removing "wapi" from the .lib and .exp files so cmake will find them
  • Do not rename the dll or pdb files - move or copy them into EmerMiscLibs/bin

Build GSL

Emergent 8.0.0 was build with gsl 1.8 using VS2015 from the VC8 project in the ??? directory (available here - https://grey.colorado.edu/emergent_ftp/gsl-1.8.zip)

  • Open libgsl.sln in Visual Studio 2015
  • Best to build both release and debug versions of the lib and dll (not the static ones!) - all 64 bit (configuration will say x64)
  • the generated files will be in VC8/x64
  • Before moving the lib and exp files into EmerMiscLibs/lib rename libgsl_dll_d.lib to gsl_d.lib
  • Do not rename the dll or pdb files - move or copy them into EmerMiscLibs/bin

Build Emergent 7 with Emergent 8 temt library

These instructions are for building and packaging Emergent 7 built using the emergent 7 library (Leabra, Network, etc) with infrastructure and gui you get with Emergent 8.

  • To do this you must first build and install emergent 8
  • Then get the source code for emergent 7
cd C:\src
mkdir emergent7  # separate src tree
cd emergent7
svn co https://grey.colorado.edu/svn/emergent/emergent/branches/emergent71 .    # get the right branch
  • There is a file named vs15init.bat in emergent7/win_build that you should look over - you probably need to update paths that have the emergent 8 version number in them
  • Open a command prompt as administrator and run the vs15init.bat file
  • Now the same steps as for building emergent 8

Be sure to always remember to do configure and making in a build subdir!!

e.g., after you run this script, you need to do something like this:

> mkdir build
> cd build
> configure
> jom -j4

This will build the entire thing, resulting in an executable in bin/emergent.exe

To install into C:\Program Files\Emergent then do:

> jom install

Building Emergent 7 Package

  • must start command prompt with administrator privileges
  • edit the CPackConfigure.cmake file that is in the emergent7/build directory
    • there are 3 lines where the path needs to be changed
    • change emergent7/src/temt/ta_gui to emergent/src/temt/ta_gui (because we are using emergent 8's temt code)
  • jom install -- key to install prior to building packages -- the installer builds packages from the *installed* version of the software
  • jom package
  • This gets you the a package but it is missing most of what is needed
  • I haven't gotten a package that actually works for emergent7 using the emergent 8 temt.dll
  • So for now just copy emergent7.exe and emergent7lib.dll into your C:\Program Files\Emergent\bin directory (created when you installed Emergent 8) and run emergent7.exe to run old emergent 7 projects.

Visual Studio Debugging

  • Possible problems in launching emergent from within VS
    • Can't find QtWebEngineProcess.exe - copy from the Qt bin directory to the emergent executable directory build_dbg\bin\Debug (If you now hit a breakpoint when you launch emergent just continue!)