Sunday, August 10, 2014

Building and Running on Windows 8.1 – Command Line

The application can also be built using the command line, either from the Windows Command Prompt or from the BASH shell that comes with Git for Windows named Git Bash in the menu or start screen.  However, the procedure is slightly different between the two.  The procedures below include cloning the IBCP Git repository.  Here are the steps for using Git Bash:
  1. cd Documents
  2. git clone https://github.com/thunder422/ibcp
  3. cd ibcp                               (shows master is the current branch)
  4. git checkout branch0.6                (now shows branch0.6 is the current branch)
  5. cd ..
  6. mkdir ibcp-build
  7. cd ibcp-build
  8. cmake -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make ../ibcp
  9. mingw32-make
  10. regtest                               (runs the Linux regression test script)
In step 8, the MSYS generator looks for the make command, which it will not find because it is named ming32-make with the MinGW-w64 installation.  Therefore the make program needs to be identified on the command line.

Here are the steps for using the Command Prompt:
  1. cd Documents
  2. git clone https://github.com/thunder422/ibcp
  3. cd ibcp
  4. git checkout branch0.6
  5. cd ..
  6. md ibcp-build
  7. cd ibcp-build
  8. cmake -G "MinGW Makefiles" ../ibcp    (produces errors - see below)
  9. cmake -G "MinGW Makefiles" ../ibcp
  10. mingw32-make
  11. regtest                               (runs Windows regression test batch file)
In steps 8 and 9, unlike the MSYS generator, the MinGW generator does look for the mingw32-make command, so the make program does not need to be specified.  In step 8 like Qt Creator, there are a bunch of errors, one screaming about sh.exe being in the path and that MinGW make won't work correctly.  This does not appear to actually affect the build however.  In step 9 again like with Qt Creator, the second time no errors are reported.

In step 11, the batch file will run all the tests and then it will compare the first set of results (parser tests).  If the tests are successful it will say OK for each file.  Answer N for comparing more files.  The next set of results will be compared.  Answer N after each comparison (otherwise it will prompt for more files to compare).

In step 8 for Git Bash and steps 8 and 9 for the Command Prompt, add -DCMAKE_BUILD_TYPE=Debug before the source directory to do a debug build.

Building and Running on Windows 8.1 – Qt Creator

To obtain the project Git repository, start the Git GUI, either from the Start Menu (Programs, Git, Git GUI), from the Start Screen Git GUI icon or by typing "Git GUI" on the Start Screen (and there are probably other ways).  For Windows 8, it probably dumped the Git GUI icon right on the Start Screen.  For Windows 8.1, click the Down Arrow at the bottom-left and find the Git GUI under Git (pin to the Start screen if desired).

In the opening dialog of Git GUI, click on Clone Existing Repository.  Enter https://github.com/thunder422/ibcp in the Source Location and set to Target Directory by clicking the Browse button.  Find the Documents folder (or another folder), and click the OK button.  To the Target Directory, add /ibcp (it must be a non-existing folder or and error will occur) and click the Clone button.  After a few moments, the repository will be cloned.  The next time the Git GUI is started, the same dialog appears, however, the Git GUI remembers the repositories that have been opened previously.  Select the Repository menu and the recent repositories are listed.

The main Git GUI will be started indicating it is on the master branch.  Check out the latest branch by Branch, Create..., click the Matching Tracking Branch Name option, click the Tracking Branch option, select origin/branch0.6 (or another branch) and click the Create button.  This will create a local branch.  Now the project can be opened in Qt Creator so start Qt Creator and select File and Open File or Project...  and navigate to the Documents and then ibcp folder.  Select the CMakeLists file (the .txt is not displayed unless file extensions are enabled) and click the Open button.  

The CMake Wizard dialog appears with the build directory set to ...\Documents\ibcp-build,  click the Next button.  For a debug build (optional) add -DCMAKE_BUILD_TYPE=Debug into the Arguments field and then click the Run CMake button.  For some reason, there are a bunch of errors the first time.  Just click the Run CMake button again and it should complete successfully.  Click the Finish button and the application is ready to be built.

To start the build, click the Hammer icon (lower left, or type Ctrl+B or use the Build menu).  The run the program, click the Run/Play icon (lower left, or type Ctrl+R or use the Build menu).  For a debug build use the Debug/Play icon (lower left, or type F5 or use the Debug menu).  The application should start in GUI mode.

[commit ec787762b9] [commit 3285823de0]

CMake Problems Windows 8.1 – Part 3

The final build problem found with the awk script used to auto-generate the automatic enumerations header file and the codes reference text file.  The problem was that when building with Qt Creator (procedure will be provided in the next post), the build aborted with a strange error message after running this script.  It correctly built the output files, and telling it to build again allowed it to successfully complete the build.

The problem was in the part of the script that generates the codes.txt reference file that lists all the codes by code index and by code name.  This information is helpful to aid debugging, but otherwise it is not used.  To sort by code names, it pipes the code name output through the sort command.  It was desired that names like Asc_Code and Asc2_Code be sorted like this, but it was reversing these because the underscore sorts after the 2 character.

An attempt to correct this issue was made be adding the "-d" option (dictionary order) to the sort command which tells it to only recognize letters and digits ignoring underscore characters.  When building under Windows, it was calling the Windows sort command.  This sort command did not recognize this option and reported an error, which caused the build to fail.

Unfortunately, adding this option did not work as desired anyway.  The problem was that with the underscores removed, the above names become AscCode and Asc2Code and the 2 character still sorted before the C character.  This was not noticed when this option was added.  Anyway, once this option was removed, the build no longer failed on Windows.  (Curiously, the Windows sort command does sort the names as desired.)