Dev:mingw

Dev:mingw - MinGW Developer's Guide (Windows only)

MinGW and Win-Builds Installation
The following procedure is used to install MinGW and Win-Builds on a Windows system:


 * 1) Download and run mingw-get-setup.exe from MinGW from SourceForge.
 * 2) * Choose the install folder c:\mingw
 * 3) * Select the graphical user interface
 * 4) * Select the start menu and desktop shortcut as you prefer.
 * 5) * Click [Continue] as necessary and respond to (re)installation conflicts if necessary.
 * 6) When the MinGW Installation Manager opens do the following:
 * 7) * Click on Basic Setup in the left pane.
 * 8) * Right-click on msys-base in the right pane and click Mark for Installation. If it's greyed out then it's already installed.
 * 9) * Click on All Packages in the left pane.
 * 10) * Right-click on mingw32-autotools and click Mark for Installation. This will select multiple other packages.
 * 11) * Select the Installation menu item and click Apply Changes.
 * 12) * Click Apply and Close after the package have been installed.
 * 13) * Quit the MinGW Installation Manager.
 * 14) Using your file browser open the folder called c:\mingw\msys\1.0\etc
 * 15) * Edit the file fstab and append the lines
 * c:\mingw /mingw
 * c:\gridlabd /home/username
 * where gridlabd is the folder in which you check out GridLAB-D code using subversion and username is your login id.
 * 1) Download and run win-builds-1.5.0.exe from Win-builds.org
 * 2) * After the extraction process completes the Win-builds installation window is displayed. Select Cygwin or MSYS and x86_64. (Select i686 if you are on a 32-bit system.) Enter the MSYS installation folder c:\mingw\msys\1.0 and click Ok.
 * 3) * When the Win-builds window is displayed. Click Process. (This process can take a few minutes.)
 * 4) Select the default architecture for your build
 * 5) * Using a DOS command window type the command
 * C:\>echo source /opt/windows_64/bin/win-builds-switch >c:\gridlabd\.profile</tt>
 * (If you are on a 32-bit system, replace "windows_64</tt>" with "windows_32</tt>".)
 * 1) Add the new mingw tools to your path environment.
 * Open the Control Panel.
 * Open the System from the right panel.
 * Click on Advanced system settings from the left panel.
 * Click on [Environment Variables] in the System Properties window.
 * Scroll the System variables selection window to PATH</tt> and click [Edit...].
 * Append the following to the existing path:
 * c:\mingw\msys\1.0\bin;c:\mingw\bin;c:\mingw\msys\1.0\opt\windows_64\bin;c:\mingw\msys\1.0\opt\windows_64\mingw\bin</tt>
 * (Use "windows_32</tt>" if appropriate.) Don't forget to place a semicolon between the existing path and path your are appending.
 * 1) Open the c:\mingw\msys\1.0</tt> folder in your windows file explorer, right-click on msys.bat</tt> and click Create a shortcut, then drag and drop the new shortcut into your Start Menu. This provides a quick and convenient way to open an MSYS window.
 * 2) Test your system by clicking on the MSYS shortcut in your start menu.
 * 3) * The MSYS window should open and display something like
 * Unset ${PKG_CONFIG_LIBDIR}.</tt>
 * Set ${PATH}=/opt/windows_64/bin:.:/usr/local/bin:/mingw/bin:/bin</tt> etc.
 * Set ${PKG_CONFIG_LIBDIR}=c:/mingw/msys/1.0/opt/windows_64/lib64/pkgconfig.</tt>
 *  </tt>
 * username@hostname ~</tt>
 * $</tt>
 * 1) * Enter "exit</tt>" at the $</tt> prompt to exit the MSYS window.

You can now proceed with Installing Eclipse.

Installing Eclipse

 * 1) Install the 64-bit version of Java (if you have not already done so).
 * 2) * Download the 64-bit Java support and follow the installation process.
 * 3) Download the 64-bit Eclipse ZIP and extract the archive contents to the folder you want Eclipse to run from, e.g., <tt>C:\Program Files</tt>. Only the archive folder <tt>eclipse</tt> should be copied to the target folder.
 * 4) (Optional) Open the new <tt>eclipse</tt> folder, right-click on <tt>eclipse.exe</tt> and click on Create shortcut.  Depending on your access rights the shortcut will either be created in the same folder or Windows will ask you if it's ok to create the shortcut on the Desktop.  Drag and drop the new shortcut into Start Menu for easy future access to Eclipse.

You can now proceed to Setup Required Libraries.

Setup Required Libraries

 * 1) Install the dlfcn and xerces-c libraries.
 * 2) * Download TortoiseSVN including the command line tools.
 * 3) * Using TortoiseSVN download the GridLAB-D source tree you wish to build into <tt>c:\gridlabd\repo</tt>, where repo is the name of the tree (e.g., <tt>trunk</tt>, <tt>ticket/863</tt>).
 * 4) Start MSYS, change directory to your repo's third-party folder for dlfnc:
 * <tt>$ cd repo/third_party/dlfnc-win32-read-only</tt>
 * Note: if you use a drive other than <tt>C:</tt> you can specify the drive letter using <tt>/c/</tt>, e.g., <tt>/c/gridlabd/repo</tt>
 * 1) * Build and install the dlfnc library
 * <tt>$ ./configure --prefix=/opt/windows_64/mingw --enable-shared</tt>
 * <tt>$ make</tt>
 * <tt>$ make install</tt>
 * 1) Change to the <tt>repo/third_party</tt>, extract, build and install the xerces-c library
 * <tt>$ cd /gridlabd/repo/third_party</tt>
 * <tt>$ tar xvf xerces-c-3.1.1.tar.gz</tt>
 * <tt>$ cd xerces-c-3.1.1</tt>
 * <tt>$ ./configure --build=x86_64-w64-mingw32 --prefix=/opt/windows_64/mingw</tt> ( Fix this so --build and --prefix are not required)
 * (On 32-bit machines use "<tt>i686</tt>" instead of "<tt>x86_64</tt>" and "<tt>windows_32</tt>" instead of "<tt>windows_64</tt>".)
 * <tt>$ make</tt>
 * <tt>$ make install</tt>

You can now proceed to Compiling GridLAB-D.

Compiling GridLAB-D

 * 1) Open an MSYS window and change to the desired repo folder:
 * <tt>$ cd /gridlabd/repo</tt>
 * 1) (Re)build the <tt>configure</tt> script, configure, make and install GridLAB-D:
 * <tt>$ autoreconf -isf</tt>
 * <tt>$ ./configure --build=x86_64-w64-mingw32 --prefix=$PWD/install64 --with-xerces=/opt/windows_64/mingw/bin --with-xerces-inc=/opt/windows_64/mingw/include --with-xerces-lib=/opt/windows_64/mingw/lib</tt> ( Fix this so --build, --prefix, and --with-* are not required)
 * <tt>$ make</tt>
 * Note: if you want to debug you must remove (e.g., comment out) the <tt>-O2</tt> options on lines 632 and 644 of the <tt>makefile</tt> file before running it.
 * <tt>$ make install</tt>

You can now proceed to Validating GridLAB-D.

Validating GridLAB-D

 * 1) Open a MSYS windows, add the new GridLAB-D to the environment path, and check the version
 * <tt>$ export PATH=$PATH:~/repo/install64/bin:~/repo/install64/lib/gridlabd</tt>
 * <tt>$ gridlabd --version</tt>
 * 1) Change to the repo and start validation
 * <tt>$ cd repo</tt>
 * <tt>$ gridlabd --validate</tt>

Running in Windows
@echo off rem rem - Use this only when running from a repo build rem set REPO=repo set MINGW=c:\mingw set PATH=%MINGW%\bin;c:\mingw\msys\1.0\opt\windows_64\bin;c:\mingw\msys\1.0\opt\windows_64\mingw\bin set GRIDLABD=c:\gridlabd\%REPO% set GLPATH=%GRIDLABD%\core;%GRIDLABD\install64\lib\gridlabd set INCLUDE=%MINGW%\include set LIB=%MINGW%\lib set args= :nextarg if "%1" == "" goto start set args=%args% %1 shift goto nextarg :start %GRIDLABD%\install64\bin\gridlabd.bin.exe %args%
 * 1) Create a <tt>gridlabd.bat</tt> file to run in GridLAB-D from a DOS prompt.  The file should look like this

Debugging in Eclipse
Note: you must build gridlabd with debugging enabled. See Compiling GridLAB-D for details.


 * 1) Open Eclipse by clicking on the Start Menu shortcut you created above.
 * 2) If asked, choose your workspace folder, e.g., a folder with the same name as your local repo (but not actually in the local repo). If you plan on working with multiple repositories, you not want make this the default workspace.
 * 3) * If this is the first time you have run Eclipse you should do a check for updates using using the menu Help->Check for Updates.
 * Note: Depending on your user privileges you may have to run Eclipse as administrator to install updates. You can do this by right-clicking on the Start Menu shortcut for Eclipse and choosing Run as Administrator.
 * 1) * If you see the Welcome screen, click on the Restore icon in left-side toolbar.
 * 2) Import the repo you wish to work on.
 * 3) * Select the menu File->Import.
 * 4) * Select the repo as the root directory.
 * 5) * Check the "gridlabd (repo)" project.
 * 6) * Click [Finish]
 * The Project Explorer pane (on the left) should now display "gridlabd". Opening this project will display all the available modules in the project.
 * 1) Setup the build environment
 * 2) * Select the Window -> Preferences menu item
 * 3) * Open the C/C++->Build->Environment preference in left pane.
 * 4) * If the Path environment variable is not set, click the [Select...] button, scroll the Variables list, check the Path variable, and click the [Ok] button.
 * 5) * Click [Ok] on the Preferences dialog box.
 * 6) * Quit Eclipse and restart it.
 * 7) * Return to the project and chosse the menu Run->External Tools->External Tools Configurations...
 * You should see the autoreconf, configure, make, make install, and validate entries under the Program item (you may have to open it). If now, you must create a new entry for each by clicking on the New Launch Configuration icon above the Program entry.  Only the Main tab must be configured with the following values:
 * autoreconf:
 * Location: <tt>C:\MinGW\msys\1.0\bin\sh.exe</tt>
 * Working directory: <tt>${workspace_loc:gridlabd}</tt>
 * Arguments: <tt>autoreconf -isf</tt>
 * configure
 * Location: <tt>C:\MinGW\msys\1.0\bin\sh.exe</tt>
 * Working directory: <tt>${workspace_loc:gridlabd}</tt>
 * Arguments: <tt>configure </tt>
 * make
 * Location: <tt>C:\MinGW\msys\1.0\bin\make.exe</tt>
 * Working directory: <tt>${workspace_loc:gridlabd}</tt>
 * Arguments:
 * make install
 * Location: <tt>C:\MinGW\msys\1.0\bin\make.exe</tt>
 * Working directory: <tt>${workspace_loc}</tt>
 * Arguments: <tt>install</tt>
 * validate
 * Location: <tt>C:\MinGW\msys\1.0\bin\sh.exe</tt>
 * Working directory: <tt>${workspace_loc:gridlabd}</tt>
 * Arguments: <tt>c:\mingw\bin\gridlabd --validate</tt>

Version
The MinGW build capability was implemented under [/863 Ticket 863]. See MinGW for details.