Building An Executable: Difference between revisions

From NARS2000
Jump to navigationJump to search
Line 39: Line 39:
To install the Microsoft Visual Studio 2008 Express C compiler, run the '''vcsetup.exe''' program.  Afterwards, the files '''msobj80.dll''', '''mspdb80.dll''', '''mspdbcore.dll''', and '''mspdbsrv.exe''' all need to be copied from '''V:\Common7\IDE''' to '''V:\VC\bin''', where the '''V''' drive is a substitute for '''C:\Program Files\Microsoft Visual Studio 9.0'''.  See the discussion below on [[#Set_Up_Makefile_Environment_Variables|Set Up Makefile Environment Variables]].
To install the Microsoft Visual Studio 2008 Express C compiler, run the '''vcsetup.exe''' program.  Afterwards, the files '''msobj80.dll''', '''mspdb80.dll''', '''mspdbcore.dll''', and '''mspdbsrv.exe''' all need to be copied from '''V:\Common7\IDE''' to '''V:\VC\bin''', where the '''V''' drive is a substitute for '''C:\Program Files\Microsoft Visual Studio 9.0'''.  See the discussion below on [[#Set_Up_Makefile_Environment_Variables|Set Up Makefile Environment Variables]].


To install the Parser Generator (Bison), run the Cygwin '''setup.exe''' program and choose the '''Devel''' category, then '''bison''' (when the Cygwin setup program asks you to choose a '''Default Text File Type''', choose '''DOS/text''' so any committed files are the same as in the version control repository).
To install the Parser Generator (Bison), see the instructions above. When the Cygwin setup program asks you to choose a '''Default Text File Type''', choose '''DOS/text''' so any committed files are the same as in the version control repository.


To install the Doctor Dump SDK, unzip it in any directory at or above %NARSROOT%.  See the discussion below on [[#Set_Up_Makefile_Environment_Variables|Set Up Makefile Environment Variables]].
To install the Doctor Dump SDK, unzip it in any directory at or above %NARSROOT%.  See the discussion below on [[#Set_Up_Makefile_Environment_Variables|Set Up Makefile Environment Variables]].

Revision as of 11:22, 21 February 2015

Platforms

The current version of NARS2000 may be built on Windows platforms only, however a goal is to enable it to built on Linux, Mac OS, etc. as per user requests and developer interests. As such, for the moment, the following description for building an executable is necessarily biased towards Windows.

Downloads

To build the executable you'll need the following

  • C Compiler and Linker
  • Make program
  • Resource Compiler
  • Windows SDK
  • Parser Generator
  • Zip Utility
  • PHP (Hypertext Preprocessor)
  • NARS2000 Source Code
  • NARS2000 External Libraries
  • Optionally, Multi-precision Library Source
  • STDINT.H header file
  • Version Control program
  • Doctor Dump SDK
  • Optionally, a File Differencing/Merge program


All of the tools you'll need are freely available. Some of them happen to be Microsoft-specific, however there is no reason more generic tools (such as DJGPP, Cygwin or MinGW) can't be used, a task I'm hoping someone will volunteer to investigate. In particular, the tools currently used are as follows:

  • C Compiler and Linker: Microsoft Visual Studio 2008 Express (requires Windows XP or later) — includes Link, Make, a Resource Compiler, and an SDK (among others)
  • Parser Generator: Bison (Save and run either setup-x86.exe or setup-x86_64.exe as appropriate to your system, Choose A Download Source: Install from Internet, Select Root Install Directory, Select Local Package Directory, Select Your Internet Connection, Choose A Download Site, Select Packages: Choose All (Default), Devel, and bison, other dependent packages will be installed along with bison)
  • Zip Utility: 7-Zip (Latest version, 32- or 64-bit, as appropriate to your system)
  • PHP (Hypertext Preprocessor): Downloads (Windows binaries/VC9 x86 Thread Safe/Latest version/Zip or Installer, your choice) (Items to Install: Entire Script Executable, and entire Extras)
  • NARS2000 Source Code: checkout (or use a Version Control program)
  • NARS2000 External Libraries: Miscellaneous Library, qdebug Library, gsl Library, and MPIR/MPFR/ECM Libraries
  • Multi-precision Library Source Code: MPIR/MPFR/ECM Source. This zipped download is large (467MB) and is needed only to reproduce the files in the MPIR/MPFR/ECM Library download so as to satisfy the requirements of the GNU General Public License (GPL) v3. For more details on using the files in the download, look in the zipped file for readme.txt. If you are happy to use the binary libraries in MPIR/MPFR/ECM Libraries, you don't need the MPIR/MPFR/ECM Source Code..
  • STDINT.H header file installed in the MS VS 2008 Express include directory (V:\VC\include -- see below)
  • Version Control program: Tortoise SVN (Current version, 32- or 64-bit depending upon your OS)
  • Doctor Dump SDK: Doctor Dump SDK
  • File Differencing/Merge program: WinMerge (Latest stable version)

Install Tools

To install the Microsoft Visual Studio 2008 Express C compiler, run the vcsetup.exe program. Afterwards, the files msobj80.dll, mspdb80.dll, mspdbcore.dll, and mspdbsrv.exe all need to be copied from V:\Common7\IDE to V:\VC\bin, where the V drive is a substitute for C:\Program Files\Microsoft Visual Studio 9.0. See the discussion below on Set Up Makefile Environment Variables.

To install the Parser Generator (Bison), see the instructions above. When the Cygwin setup program asks you to choose a Default Text File Type, choose DOS/text so any committed files are the same as in the version control repository.

To install the Doctor Dump SDK, unzip it in any directory at or above %NARSROOT%. See the discussion below on Set Up Makefile Environment Variables.

Install the rest of the tools as per their separate instructions.

Install The Source Code

  1. First create a root folder somewhere on one of your hard drives, perhaps calling it NARS2000, as in C:\NARS2000 or perhaps at some lower level. The source code and external libraries are installed at or below this level.
  2. Under the root folder make two folders: trunk and msieve. The first folder holds the main body of code. The latter is used for the code used to factor numbers.
  3. Using a Version Control program such as TortoiseSVN, download the source code (see Check Out The Source Code),
  4. Download the misc.zip, qdebug.zip, gsldir.zip, and mplibs.zip files into the root folder and unzip them using 7z.exe as in 7z x misc.zip, 7z x qdebug.zip, 7z x gsldir.zip, and 7z x mplibs.zip.

Check Out The Source Code

An easy way to initialize your copy of the source code for the first time is to use a version control program such as TortoiseSVN mentioned above. After installing this program, there are two directories you'll need to install.

  • First, bring up Windows Explorer, right-click on the trunk folder, and choose SVN Checkout.... The URL of repository: is https://nars2000.googlecode.com/svn/trunk and the Checkout directory: is C:\NARS2000\trunk (or wherever your trunk folder is) — quite likely you will have to edit this field as the default text inserted by TortoiseSVN usually ends with NARS2000.
  • Second, bring up Windows Explorer, right-click on the msieve folder, and choose SVN Checkout.... The URL of repository: is https://nars2000.googlecode.com/svn/msieve and the Checkout directory: is C:\NARS2000\msieve (or wherever your msieve folder is)

In both cases, the Checkout Depth should be Fully recursive. Click on OK to initialize your copy of the source code.

The above steps need be done only once in order to establish the special hidden SVN directories.

You will still need to download and unzip qdebug.zip, misc.zip, gsldir.zip, and mplibs.zip as described above.

Subsequently, you may update your copy of the source code by right-clicking on the trunk and/or msieve folders and choose SVN Update.

Folders

After unzipping the above files, the structure under the root folder should look something like the following where some of the lower level directories have been omitted:

branches\
ecm\
gsl\
mpfr\
mpir\
msieve\
qdebug\
trunk\
trunk\binaries\
trunk\Extensions\
trunk\htdocs\
trunk\images\
trunk\MediaWiki\
trunk\ReleaseNotes\
trunk\WineHQ\

Choose How To Build

The following sections describe two alternate ways to build the executable. One is the GUI interface of VC++ Express, the other is a command line interface using a makefile.

Set Up VC++ Express

If you are using VC++ Express, the project file is in the trunk folder and is called NARS2000.vcproj. You may load it manually every time you invoke VC++ Express, or you may load it automatically by placing the path to the project file on the command line in the VC++ Express shortcut as in "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe" C:\NARS2000\trunk\NARS2000.vcproj or wherever you defined your NARS2000 root folder.

The vast majority of the project settings are found in the above file with some exceptions.

Set Up Makefile Environment Variables

If you are building from the makefile, you'll need to set some environment variables in your autoexec.bat file:

REM Path of the root of the NARS2000 project *ending with a backslash*
Set NARSROOT=C:\NARS2000^\

REM Path to Doctor Dump SDK root
Set CS_DIR=C:\DoctorDumpSDK^\

REM Path and name of zip program (7-Zip)
Set ZIPPRG="C:\Program Files\7-Zip\7z"

REM Path and name of parser generator (bison)
Set PARGEN=C:\Cygwin\bin\bison

REM Path and name of makedep program
Set MAKEDEP=%NARSROOT%makedep.php

REM Path and name of the <makepro.php> program
Set MAKEPRO=%NARSROOT%makepro.php

REM Folder of SDK ("C:\Program Files\Microsoft SDKs\Windows\v7.0A")
Set SDK=U:^\

REM MSVC compiler ("C:\Program Files\Microsoft Visual Studio 9.0")
Set MSVC=V:\VC^\

I find it convenient to use the Windows subst command to map drive letters as in the references to drives U: and V: above.

subst U: "C:\Program Files\Microsoft SDKs\Windows\v7.0A" (or whatever the current version is)
subst V: "C:\Program Files\Microsoft Visual Studio 9.0" (...)

If you install the above tools in other folders, make the appropriate changes to the above lines.

You will also have to append the folders C:\Cygwin\bin and V:\Common7\IDE to your path (PATH=%PATH%;C:\Cygwin\bin;V:\Common7\IDE) so the C compiler can find some of its DLLs and tools.

Building The Executable

At this point you should be ready to build the executable. To do this from VC++ Express (having already opened the project file), click on the menu item Build | Build Solution or press F7. To do this from a makefile, type mkn.