Building An Executable: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 16: Line 16:
* NARS2000 Source Code
* NARS2000 Source Code
* NARS2000 External Libraries
* NARS2000 External Libraries
* Optionally, Source Control program
* Optionally, Version Control program
* Optionally, a Code Merge program
* Optionally, a Code 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 [http://www.delorie.com/djgpp/ DJGPP], [http://www.cygwin.com/ Cygwin] or [http://www.mingw.org/ MinGW]) can't be used, a task I'm hoping someone will volunteer to investigate.  In particular, the tools currently used are as follows:
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 [http://www.delorie.com/djgpp/ DJGPP], [http://www.cygwin.com/ Cygwin] or [http://www.mingw.org/ MinGW]) can't be used, a task I'm hoping someone will volunteer to investigate.  In particular, the tools currently used are as follows:
Line 25: Line 25:
* Zip Utility:  [http://www.7-zip.org/ 7-Zip]
* Zip Utility:  [http://www.7-zip.org/ 7-Zip]
* PHP (Hypertext Preprocessor):  [http://www.php.net/downloads.php Downloads]
* PHP (Hypertext Preprocessor):  [http://www.php.net/downloads.php Downloads]
* NARS2000 Source Code:  [http://svn.nars2000.org/viewvc.cgi/trunk.tar.gz?view=tar tar ball]
* NARS2000 Source Code:  [http://svn.nars2000.org/viewvc.cgi/trunk.tar.gz?view=tar tar ball] (or use a Version Control program)
* NARS2000 External Libraries:  [http://www.nars2000.org/download/binaries/qdebug.zip qdebug Library] [http://www.nars2000.org/download/binaries/misc.zip miscellaneous files] [http://www.nars2000.org/download/binaries/gsldir.zip gsl Library]
* NARS2000 External Libraries:  [http://www.nars2000.org/download/binaries/qdebug.zip qdebug Library] [http://www.nars2000.org/download/binaries/misc.zip miscellaneous files] [http://www.nars2000.org/download/binaries/gsldir.zip gsl Library]
* Source Control program:  [http://tortoisesvn.net/downloads Tortoise SVN]
* Version Control program:  [http://tortoisesvn.net/downloads Tortoise SVN]
* Code Merge program:  [http://winmerge.org/ WinMerge]
* Code Differencing/Merge program:  [http://winmerge.org/ WinMerge]


==Install Tools==
==Install Tools==
Line 36: Line 36:
==Install Source Code==
==Install Source Code==


First create a '''root directory''' 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 below this level.
<ol>
  <li>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 below this level.</li>
  <li>Under the root folder make two folders:  one called '''trunk''' and the other called '''branches'''.  The former folder holds the main body of code.  The latter is used for developer-specific branches not as yet incorporated into the main trunk.</li>
  <li>Choose one of the following two steps:
    <ul>
      <li>Use a Version Control program such as '''TortoiseSVN''' to download the source code (see [[#Checking_Out_The_Source_Code|Checking Out The Source Code]]), '''OR'''</li>
      <li>Download the source code tar ball ('''trunk.tar.gz''') into the root folder and decompress it with '''tar zxvf trunk.tar.gz'''.  The '''tar''' program is part of Cygwin and is found in '''C:\Cygwin\bin''' (or wherever you installed Cygwin).  This command also creates the '''trunk''' folder and several folders below that.</li>
    </ul>
  </li>
  <li>Download the '''qdebug.zip''', '''misc.zip''', and '''gsldir.zip''' files into the '''trunk''' folder and unzip them using '''7z.exe''' as in '''7z x qdebug.zip''', '''7z x misc.zip''', and '''7z x gsldir.zip'''.</li>
</ol>


Download the source code tar ball ('''trunk.tar.gz''') into the root directory and decompress it with '''tar zxvf trunk.tar.gz'''.  The '''tar''' program is part of Cygwin and is found in '''C:\Cygwin\bin''' (or wherever you installed Cygwin).  This command also creates the '''trunk''' directory and several directories below that.
==Checking Out The Source Code==


Under the root directory (at the same level as the '''trunk''' directory), also make a directory called '''branches'''.  The former directory holds the main body of code.  The latter directory is used for developer-specific branches not as yet incorporated into the main trunk.
An alternate 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, bring up Windows Explorer, right-click on the '''trunk''' folder, and choose '''SVN Checkout...'''.  The '''URL of repository:''' is '''svn://svn.nars2000.org/nars2000/trunk''' and the '''Checkout directory:''' is '''C:\NARS2000\trunk''' (or wherever your '''trunk''' folder is) &mdash; quite likely you will have to edit this field as the default text inserted by TortoiseSVN usually ends with '''NARS2000'''.  The '''Checkout Depth''' should be '''Fully recursive'''.  Click on '''OK''' to initialize your copy of the source code.  This step need be done only once in order to establish the special hidden SVN directories.


Download the '''qdebug.zip''', '''misc.zip''', and '''gsldir.zip''' files into the '''trunk''' directory and unzip them using '''7z.exe''' as in '''7z x qdebug.zip''', '''7z x misc.zip''', and '''7z x gsldir.zip'''.
You will still need to download and unzip '''qdebug.zip''', '''misc.zip''', and '''gsldir.zip''' as described above.


==Directories==
Subsequently, you may update your copy of the source code by right-clicking on the '''trunk''' folder and choose '''SVN Update'''.


After unzipping the above files, the directory structure under the root directory should look something like
==Folders==
 
After unzipping the above files, the structure under the root folder should look something like
<pre>
<pre>
branches\
branches\
Line 117: Line 129:
==Set Up VC++ Express==
==Set Up VC++ Express==


If you are using VC++ Express, the project file is in the '''trunk''' directory 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 directory.
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.
The vast majority of the project settings are found in the above file with some exceptions.
Line 124: Line 136:


<ul>
<ul>
   <li>In the lefthand pane, select '''VC++ Directories'''.  In the righthand pane, in the '''Show directories for:''' combobox, select '''Include files'''.  Append to the '''end''' of the list of include directories '''.\gsl\include'''.</li>
   <li>In the lefthand pane, select '''VC++ Directories'''.  In the righthand pane, in the '''Show directories for:''' combobox, select '''Include files'''.  Append to the '''end''' of the list of include folders '''.\gsl\include'''.</li>
   <li>In the lefthand pane, select '''VC++ Project Settings'''.  In the righthand pane, enter in '''Rule File Search Paths''', the NARS2000 root directory (e.g., '''C:\NARS2000\trunk''').</li>
   <li>In the lefthand pane, select '''VC++ Project Settings'''.  In the righthand pane, enter in '''Rule File Search Paths''', the NARS2000 root folder (e.g., '''C:\NARS2000\trunk''').</li>
   <li>Click '''OK''' to close the '''Options''' dialog.
   <li>Click '''OK''' to close the '''Options''' dialog.
</ul>
</ul>
Line 139: Line 151:
Set PARGEN=C:\Cygwin\bin\bison
Set PARGEN=C:\Cygwin\bin\bison


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


Line 152: Line 164:
</pre>
</pre>


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


You will also have to append the directories '''V:\Common7\IDE''' and '''V:\VC\bin''' to your path so the C compiler can find some of its DLLs and tools.
You will also have to append the folders '''V:\Common7\IDE''' and '''V:\VC\bin''' to your path so the C compiler can find some of its DLLs and tools.


==Building The Executable==
==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 '''mk32'''.
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 '''mk32'''.

Revision as of 23:48, 22 January 2009

Platforms

The current version of NARS2000 runs on Windows platforms only, however the goal is to move it to 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, Version Control program
  • Optionally, a Code 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:

Install Tools

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). Install the rest of the tools as per their separate instructions.

Install 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 below this level.
  2. Under the root folder make two folders: one called trunk and the other called branches. The former folder holds the main body of code. The latter is used for developer-specific branches not as yet incorporated into the main trunk.
  3. Choose one of the following two steps:
    • Use a Version Control program such as TortoiseSVN to download the source code (see Checking Out The Source Code), OR
    • Download the source code tar ball (trunk.tar.gz) into the root folder and decompress it with tar zxvf trunk.tar.gz. The tar program is part of Cygwin and is found in C:\Cygwin\bin (or wherever you installed Cygwin). This command also creates the trunk folder and several folders below that.
  4. Download the qdebug.zip, misc.zip, and gsldir.zip files into the trunk folder and unzip them using 7z.exe as in 7z x qdebug.zip, 7z x misc.zip, and 7z x gsldir.zip.

Checking Out The Source Code

An alternate 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, bring up Windows Explorer, right-click on the trunk folder, and choose SVN Checkout.... The URL of repository: is svn://svn.nars2000.org/nars2000/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. The Checkout Depth should be Fully recursive. Click on OK to initialize your copy of the source code. This step 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, and gsldir.zip as described above.

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

Folders

After unzipping the above files, the structure under the root folder should look something like

branches\
trunk\
trunk\binaries\
trunk\binaries\COM\
trunk\Extensions\
trunk\Extensions\aplchars\
trunk\Extensions\aplchars\chrome\
trunk\Extensions\aplchars\chrome\content\
trunk\Extensions\aplchars\chrome\content\aplchars\
trunk\Extensions\aplchars\chrome\locale\
trunk\Extensions\aplchars\chrome\locale\en-US\
trunk\Extensions\aplchars\chrome\locale\en-US\aplchars\
trunk\Extensions\aplchars\chrome\skin\
trunk\Extensions\aplchars\chrome\skin\classic\
trunk\Extensions\aplchars\chrome\skin\classic\aplchars\
trunk\Extensions\aplchars\defaults\
trunk\Extensions\aplchars\defaults\preferences\
trunk\gsl\
trunk\gsl\.libs\
trunk\gsl\blas\
trunk\gsl\block\
trunk\gsl\cblas\
trunk\gsl\cblas\.libs\
trunk\gsl\complex\
trunk\gsl\eigen\
trunk\gsl\include\
trunk\gsl\include\arpa\
trunk\gsl\include\asm\
trunk\gsl\include\cygwin\
trunk\gsl\include\gsl\
trunk\gsl\include\machine\
trunk\gsl\include\mingw\
trunk\gsl\include\mingw\sys\
trunk\gsl\include\net\
trunk\gsl\include\netinet\
trunk\gsl\include\sys\
trunk\gsl\include\w32api\
trunk\gsl\include\w32api\ddk\
trunk\gsl\include\w32api\GL\
trunk\gsl\linalg\
trunk\gsl\matrix\
trunk\gsl\permutation\
trunk\gsl\sort\
trunk\gsl\specfunc\
trunk\gsl\statistics\
trunk\gsl\vector\
trunk\htdocs\
trunk\htdocs\art\
trunk\htdocs\download\
trunk\htdocs\styles\
trunk\images\
trunk\MediaWiki\
trunk\MediaWiki\art\
trunk\MediaWiki\extensions\
trunk\qdebug
trunk\ReleaseNotes\
trunk\WineHQ\
trunk\WineHQ\Include\
trunk\WineHQ\Include\msvcrt\
trunk\WineHQ\Include\msvcrt\sys\
trunk\WineHQ\Include\msvcrt\Wine\

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.

Open VC++ Express and select from the menu Tools | Options.... In the Options dialog lefthand pane, select Projects and Solutions.

  • In the lefthand pane, select VC++ Directories. In the righthand pane, in the Show directories for: combobox, select Include files. Append to the end of the list of include folders .\gsl\include.
  • In the lefthand pane, select VC++ Project Settings. In the righthand pane, enter in Rule File Search Paths, the NARS2000 root folder (e.g., C:\NARS2000\trunk).
  • Click OK to close the Options dialog.

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 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 Folder of SDK ("C:\Program Files\Microsoft SDKs\Windows\v6.0A")
Set SDK=U:\

REM MSVC compiler ("C:\Program Files\Microsoft Visual Studio 9.0")    (Version 15.00.30729.01)
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\v6.0A"
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 V:\Common7\IDE and V:\VC\bin to your path 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 mk32.