Difference between revisions of "DSA Software Development Environment"

From David Vernon's Wiki
Jump to: navigation, search
(DSA Data Structures and Algorithms for Engineers Repository)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
This guide provides a step-by-step guide to downloading, installing, and using the software required to submit an assignment for course 04-630 Data Structures and Algorithms for Engineers.  This environment is required to ensure that software developed by students can be compiled directly by the course instructor after it has been submitted.
+
__TOC__
 +
The following is a step-by-step guide to downloading, installing, and using the software required to submit an assignment for course 04-630 Data Structures and Algorithms for Engineers.  This environment is required to ensure that software developed by students can be compiled directly by the course instructor after it has been submitted.
  
 
<span style="color:#FF0000">Follow these instructions exactly as they are stated. Do not be tempted to skip through them, assuming that you will be able to figure it out yourself.  You might, but it is more likely you will miss something small but important and it won't work as required.  Take your time, follow these instructions carefully, and everything will work.</span>
 
<span style="color:#FF0000">Follow these instructions exactly as they are stated. Do not be tempted to skip through them, assuming that you will be able to figure it out yourself.  You might, but it is more likely you will miss something small but important and it won't work as required.  Take your time, follow these instructions carefully, and everything will work.</span>
Line 6: Line 7:
 
=== Operating System ===
 
=== Operating System ===
  
I assume you are running Windows 10.
+
I assume you are running Windows 11.
  
I strongly recommend you turn off the option in Windows Explorer to hide file extensions. To do this, from Windows Explorer menu bar select Tools > Folder Options > View and make sure the tick box labelled Hide extensions for known file types is not ticked. If it is ticked, you will have problems identifying certain files later on (e.g. invoking the <span style="color:#FF0000">example.sln</span> solution file to launch the C++ compiler).
+
I strongly recommend you turn off the option in the File Explorer to hide file extensions. To do this, on the File Explorer menu bar click the "..." icon and select Options > View. Make sure the tick box labelled "Hide extensions for known file types" is not ticked.   If it is ticked, you will have problems identifying certain files later on (e.g. invoking the <span style="color:#FF0000">example.sln</span> solution file to launch the Visual Studio C++ compiler). Select "Apply" after you untick the box.
  
If the Windows Explorer menu bar isn't visible, select Organize > Layout > Menu bar
 
  
 
=== C/C++ Compiler ===  
 
=== C/C++ Compiler ===  
  
Download the Microsoft Visual C++ Express compiler, version 10.0 (also known as Visual C++ 2010 or MSVC++ 2010).  It is important to use this version; earlier versions are no longer supported by Microsoft and later versions cause problems with some libraries.  
+
Download Microsoft Visual Studio Community.  
  
You can download the required installer from [http://www.vernon.eu/downloads/vc_web.exe here].
+
You can download the required installer from the [https://visualstudio.microsoft.com/vs/pricing/?tab=individual Microsoft website] or  [http://www.vernon.eu/DSA/VisualStudioSetup.exe here].
  
Run the installer and follow the instructions.
+
Run the installer and follow the instructions. Be sure to install Visual Studio Community 2022.
 +
 
 +
 
 +
[[File:Visual_Studio_Installer_01.png]]
 +
 
 +
 
 +
Select Desktop Development with C++ and click "Install" or "Install While Downloading".
 +
 
 +
 
 +
[[File:Visual_Studio_Installer_02.png]]
  
You will need to register Visual C++ 2010 Express to continue using beyond the initial 30-day evaluation period.  To do this, from the Microsoft Visual C++ 2010 Express menu, select ''Help > Register Product''.  You will then have to log in to your Microsoft account, if you have one, or create a new one, if you don't.  After filling in some forms you will get the product key which you enter into the dialogue box that popped up when you selected  ''Help > Register Product''.
 
  
 
=== CMake ===
 
=== CMake ===
Download CMake binaries from [http://www.cmake.org/download/ here].  At time of writing the latest version is 3.7.1.
 
<!-- Download CMake 2.8.10-RC3 binaries from [https://cmake.org/files/v2.8/cmake-2.8.10-rc3-win32-x86.exe here] -->
 
  
You can opt for either the WIN32 installer (cmake-3.7.1-win32-x86.msi) or the Windows zip file.  The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process). If you choose the installer option, note that if you already have CMake version 3.4 or earlier you must uninstall it first.
+
Download CMake binaries from [http://www.cmake.org/download/ here].  At time of writing the latest version is 3.30.0.
 +
 
 +
You can opt for either the WIN32 installer (cmake-3.30.0-windows-x86_64.msi) or the Windows zip file.  The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process). If you choose the installer option, note that if you already have CMake version 3.4 or earlier you must uninstall it first.
 +
 
 +
Here are the installation steps.
 +
 
 +
 
 +
Click "Next".
 +
 
 +
[[File:CMake_Installer_01.png]]
 +
 
 +
 
 +
Click the checkbox to accept the term, and click "Next".
 +
 
 +
[[File:CMake_Installer_02.png]]
 +
 
 +
 
 +
Click the checkbox to add CMake to the PATH environment variable, and click "Next".
 +
 
 +
[[File:CMake_Installer_03.png]]
 +
 
 +
 
 +
Use the default install path, and click "Next".
 +
 
 +
[[File:CMake_Installer_04.png]]
 +
 
 +
 
 +
Click "Install".
 +
 
 +
[[File:CMake_Installer_05.png]]
 +
 
 +
 
 +
Click "Yes" to enable the files to be installed.
 +
 
 +
[[File:CMake_Installer_06.png]]
 +
 
 +
 
 +
Click "Finish".
 +
 
 +
[[File:CMake_Installer_07.png]]
 +
 
  
 
=== DSA Data Structures and Algorithms for Engineers Repository ===
 
=== DSA Data Structures and Algorithms for Engineers Repository ===
Line 32: Line 78:
 
Copy the DSA repository to the <span style="color:#FF0000"><span style="color:#FF0000"><code>C:</code></span></span>  drive:
 
Copy the DSA repository to the <span style="color:#FF0000"><span style="color:#FF0000"><code>C:</code></span></span>  drive:
  
* Download a zip archive with all the files from  [http://www.vernon.eu/downloads/DSA.zip here].
+
* Download a zip archive with all the files from  [http://www.vernon.eu/DSA/DSA.zip here].
* Copy it to <span style="color:#FF0000"><span style="color:#FF0000"><code>C:</code></span></span> drive and unzip it so that you have a directory called <span style="color:#FF0000"><code>C:\DSA</code></span>.
+
* Copy it to <span style="color:#FF0000"><span style="color:#FF0000"><code>C:</code></span></span> drive and unzip it so that you have a directory called <span style="color:#FF0000"><code>C:/DSA</code></span>.
  
  
<span style="color:#FF0000"><code>C:\DSA</code></span> has with a sub-directory structure explained in class. For our purposes here, there is an  <span style="color:#FF0000"><code>C:\DSA\assignments</code></span>  directory and it will contain an example <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0</code></span> sub-directory. Later on, you will generate <span style="color:#FF0000"><code>C:\DSA\assignments\assignment1</code></span> and <span style="color:#FF0000"><code>C:\DSA\assignments\assignment2</code></span>, and so on.   
+
<span style="color:#FF0000"><code>C:/DSA</code></span> has with a sub-directory structure explained in class. For our purposes here, there is an  <span style="color:#FF0000"><code>C:/DSA/assignments</code></span>  directory and it will contain an example <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0</code></span> sub-directory. Later on, you will generate <span style="color:#FF0000"><code>C:/DSA/assignments/assignment1</code></span> and <span style="color:#FF0000"><code>C:/DSA/assignments/assignment2</code></span>, and so on.   
  
There is also a <span style="color:#FF0000"><code>C:\DSA\lectures</code></span> sub-directory. Later, I will make available the code from the lectures together with instructions on how to add it to the repository: the source code will go in the <span style="color:#FF0000"><code>C:\DSA\lectures\src</code></span> sub-directory and test data will go in the <span style="color:#FF0000"><code>C:\DSA\lectures\data</code></span> sub-directory.
+
There is also a <span style="color:#FF0000"><code>C:/DSA/lectures</code></span> sub-directory. This has some simple examples of standard data structures and algorithms.  Later in the course, I will make available the code from the lectures, together with instructions on how to add it to the repository: the source code will go in the <span style="color:#FF0000"><code>C:/DSA/lectures/src</code></span> sub-directory and test data will go in the <span style="color:#FF0000"><code>C:/DSA/lectures/data</code></span> sub-directory.
  
 +
[[File:DSA_Installation_17.png]]
  
The next step is to build a MSVC++ <span style="color:#FF0000"><code>.sln</code></span> solution file so that you can compile the DSA assignment0 executable. To do this, you need to run CMake against the <span style="color:#FF0000"><code>C:DSA\assignments\assignment0</code></span> directory (where you will find the main <span style="color:#FF0000"><code>CMakeLists.txt</code></span> file).    We use <span style="color:#FF0000"><code>assignment0</code></span> because it is a dummy assignment but you will follow exactly the same procedure for all the real assignments.
+
The next step is to build a Visual Studio <span style="color:#FF0000"><code>.sln</code></span> solution file so that you can compile (i.e., build) the DSA assignment0 executable. To do this, you need to run CMake against the <span style="color:#FF0000"><code>C:DSA/assignments/assignment0</code></span> directory (where you will find the main <span style="color:#FF0000"><code>CMakeLists.txt</code></span> file).    We use <span style="color:#FF0000"><code>assignment0</code></span> because it is a dummy assignment but you will follow exactly the same procedure for all the real assignments.
  
* Launch the CMake GUI from the Windows 7 toolbar.
+
Launch the CMake GUI from the Windows 11 taskbar.
  
* In the ''Where is the source code:'' type (or browse to)  <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0</code></span>
 
  
* In the ''Where to build the binaries:'' type (or browse to) <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\build</code></span>
+
[[File:DSA_Installation_01.png]]
  
* Select ''File > Delete Cache'' from the top menu (you '''must''' do this the first time in case there is an old invalid configuration in the DSA directory)
 
  
* Click ''Configure''
+
In the ''Where is the source code:'' type (or browse to)  <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0</code></span>
  
* Select Visual Studio 10 (2010) from the drop-down menu as the generator for the project
 
  
* Click ''Finish'' and watch CMake configure your project.  The dialogue box will still highlighted in red, so ...
+
[[File:DSA_Installation_02B.png]]
  
* Click ''Configure'' two more times and everything should be fine.
 
  
* Click ''Generate'' to create the MSVC++ <span style="color:#FF0000"><code>assignment0.sln</code></span> file in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\build</code></span> directory.
+
In the ''Where to build the binaries:'' type (or browse to) <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/build</code></span>
  
  
Now you are ready to launch MSVC++ and build the DSA assignment0 executable.
+
[[File:DSA_Installation_03B.png]]
  
* Go to the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\build</code></span> directory and double-click the <span style="color:#FF0000"><code>assignment0.sln</code></span> file.  This launches Microsoft Visual C++ 2010 Express.
 
  
* Select <span style="color:#FF0000"><code>Release</code></span> in the ''Solutions Configuration'' box (this is located left of centre on the toolbar and defaults to <span style="color:#FF0000"><code>Debug</code></span>).
+
Select ''File > Delete Cache'' from the top menu (you '''must''' do this the first time in case there is an old invalid configuration in the DSA directory)
  
* Select ''Build > Build Solution'' from the top menu, (if you don't see this and you see  ''Debug > Build Solution'' instead, it's probably because your IDE is set to basic settings. To change this, select ''Tools > Settings > Expert Settings'').
 
  
This will compile and link the programs in the the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\src</code></span> sub-directory and install then in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\bin</code></span> directory.  
+
[[File:DSA_Installation_04B.png]]
  
  
Check to see that the example <span style="color:#FF0000"><code>dvernon.exe</code></span> executable is thereIf it is not, then select ''Build > Configuration Manager'' from the menu and make sure the ''INSTALL'' check-box is ticked.  Now rebuild the project again.   
+
Click ''Configure''
 +
 
 +
 
 +
[[File:DSA_Installation_05B.png]]
 +
 
 +
 
 +
Select Visual Studio 17 20122 from the drop-down menu as the generator for the project
 +
 
 +
 
 +
[[File:DSA_Installation_06.png]]
 +
 
 +
 
 +
 
 +
Click ''Finish'' and watch CMake configure your project (this will take a few seconds so please be patient).
 +
 
 +
 
 +
[[File:DSA_Installation_07.png]]
 +
 
 +
 
 +
 
 +
The text in dialogue box will be highlighted in red, so click ''Configure'' one more time and everything should be fine.
 +
 
 +
 
 +
[[File:DSA_Installation_08.png]]
 +
 
 +
 
 +
Click ''Generate'' to create the Visual Studio <span style="color:#FF0000"><code>assignment0.sln</code></span> file in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/build</code></span> directory.
 +
 
 +
 
 +
[[File:DSA_Installation_09.png]]
 +
 
 +
 
 +
Now you are ready to launch Visual Studio and build the DSA assignment0 executable.   
 +
 +
 
 +
Go to the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/build</code></span> directory and double-click the <span style="color:#FF0000"><code>assignment0.sln</code></span> file.  This launches Microsoft Visual Studio.
 +
 
 +
 
 +
[[File:DSA_Installation_10.png]]
 +
 
 +
 
 +
Select <span style="color:#FF0000"><code>Release</code></span> in the ''Solutions Configuration'' box (this is located left of centre on the toolbar and defaults to <span style="color:#FF0000"><code>Debug</code></span>).
 +
 
 +
 
 +
[[File:DSA_Installation_11.png]]
 +
 
 +
 
 +
Select ''Build > Configuration Manager'' from the menu and make sure the ''INSTALL'' check-box is ticked.   
  
 
'''Note that you will have to tick this check-box every time you rebuild the <span style="color:#FF0000"><code>.sln</code></span> solution file with CMake.'''  If you don't do this, then your new executable won't be installed in the <span style="color:#FF0000"><code>bin</code></span> directory and you'll end up becoming very confused because none of the changes you make to your source code will be reflected in the executable you run from the <span style="color:#FF0000"><code>bin</code></span> directory (because its an old version from a previous compilation).
 
'''Note that you will have to tick this check-box every time you rebuild the <span style="color:#FF0000"><code>.sln</code></span> solution file with CMake.'''  If you don't do this, then your new executable won't be installed in the <span style="color:#FF0000"><code>bin</code></span> directory and you'll end up becoming very confused because none of the changes you make to your source code will be reflected in the executable you run from the <span style="color:#FF0000"><code>bin</code></span> directory (because its an old version from a previous compilation).
  
  
Good!  Now you are now ready to run the example <span style="color:#FF0000"><code>dvernon.exe</code></span>  application that is provided with the DSA release. To do this, double click the< code>dvernon.exe</code></span> executable in <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\bin</code></span>.  Open <span style="color:#FF0000"><code>input.txt</code></span> file in <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\data</code></span>and, after running <span style="color:#FF0000"><code>dvernon.exe</code></span>, open the <span style="color:#FF0000"><code>output.txt</code></span> file, also in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\data</code></span> directory.
+
[[File:DSA_Installation_12.png]]
  
  
Try creating your own (dummy) assignment program. To do this, follow the following steps.
+
[[File:DSA_Installation_13.png]]
  
* Create a directory with your Andrew Id, e.g.  <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\src\myandrewid</code></span>
+
 
 +
Select ''Build > Build Solution'' from the top menu.
 +
 
 +
This will compile and link the programs in the the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/src</code></span> sub-directory and install then in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/bin</code></span> directory.
 +
 
 +
 
 +
[[File:DSA_Installation_14.png]]
 +
 
 +
 
 +
Good!  Now you are now ready to run the example <span style="color:#FF0000"><code>dvernon.exe</code></span>  application that is provided with the DSA release. To do this, double click the <code>dvernon.exe</code></span> executable in <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/bin</code></span>. 
 +
 
 +
 
 +
[[File:DSA_Installation_15.png]]
 +
 
 +
 
 +
Inspect the source code for this dummy assignment in Visual Studio. 
 +
 
 +
Open  <span style="color:#FF0000"><code>exampleApplication.cpp</code></span> in the Source Files folder, and read the internal documentation and the code.  Do the same with <span style="color:#FF0000"><code>exampleImplementationion.cpp</code></span>.
 +
 
 +
Now open <span style="color:#FF0000"><code>example.h</code></span> in the Header Files folder and read the internal documentation and the code.
 +
 
 +
 
 +
[[File:DSA_Installation_16.png]]
 +
 
 +
 
 +
Now that you understand what this program does, open <span style="color:#FF0000"><code>assignment0Input.txt</code></span> file in <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/data</code></span> and inspect its contents. After running <span style="color:#FF0000"><code>dvernon.exe</code></span>, open the <span style="color:#FF0000"><code>assignment0Output.txt</code></span> file, also in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/data</code></span> directory, and inspect its contents.  Verify that the contents are as you expect them to be.
 +
 
 +
 
 +
Finally,  create your own (dummy) assignment program. To do this, follow these steps.
 +
 
 +
* Create a directory with your Andrew Id, e.g.  <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/src/myandrewid</code></span>
 
* Copy the source files (<span style="color:#FF0000"><code>.c, .cpp, .h</code></span>) from the <span style="color:#FF0000"><code>dvernon</code></span> directory to the myandrewid directory.
 
* Copy the source files (<span style="color:#FF0000"><code>.c, .cpp, .h</code></span>) from the <span style="color:#FF0000"><code>dvernon</code></span> directory to the myandrewid directory.
* Edit the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\src\CMakeLists.txt</code></span> file and replace <span style="color:#FF0000"><code>ADD_SUBDIRECTORY(dvernon)</code></span> with <span style="color:#FF0000"><code>ADD_SUBDIRECTORY(myandrewid)</code></span>, where <span style="color:#FF0000"><code>myandrewid</code></span> is your Andrew Id.   
+
* Edit the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/src/CMakeLists.txt</code></span> file and replace <span style="color:#FF0000"><code>ADD_SUBDIRECTORY(dvernon)</code></span> with <span style="color:#FF0000"><code>ADD_SUBDIRECTORY(myandrewid)</code></span>, where <span style="color:#FF0000"><code>myandrewid</code></span> is your Andrew Id.   
* Edit the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\src\myandrewid\CMakeLists.txt</code></span> file and replace <span style="color:#FF0000"><code>dvernon</code></span> with <span style="color:#FF0000"><code>myandrewid</code></span>, where <span style="color:#FF0000"><code>myandrewid</code></span> is your Andrew Id.  
+
* Edit the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/src/myandrewid/CMakeLists.txt</code></span> file and replace <span style="color:#FF0000"><code>dvernon</code></span> with <span style="color:#FF0000"><code>myandrewid</code></span>, where <span style="color:#FF0000"><code>myandrewid</code></span> is your Andrew Id.  
 
* Run CMake again.   
 
* Run CMake again.   
* Re-open the <span style="color:#FF0000"><code>assignment0.sln</code></span> file (remember, it's in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\build</code></span> directory).  
+
* Re-open the <span style="color:#FF0000"><code>assignment0.sln</code></span> file (remember, it's in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/build</code></span> directory).  
* Your files should now be visible (and the dvernon ones will no longer be there) and you can now compile your code and install it in the <span style="color:#FF0000"><code>bin</code></span> directory by selecting ''Build > Build Solution'' from the top menu.   
+
* Your files should now be visible (and the dvernon ones will no longer be there) and you can now edit your code (change dvernon to your Andrew ID in the assignment0Application.cpp file, compile it, and install it in the <span style="color:#FF0000"><code>bin</code></span> directory by selecting ''Build > Build Solution'' from the top menu.   
* Make sure that the ''INSTALL'' check-box is ticked when you select ''Build > Configuration Manager'' from the menu to ensure that your executable is installed in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\bin</code></span> directory.     
+
* Make sure that the ''INSTALL'' check-box is ticked when you select ''Build > Configuration Manager'' from the menu to ensure that your executable is installed in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/bin</code></span> directory.     
* Finally, run your program in the <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\bin</code></span> directory. You might like to change the contents of <span style="color:#FF0000"><code>input.txt</code></span> in the  <span style="color:#FF0000"><code>C:\DSA\assignments\assignment0\data</code></span> directory and re-run your program to convince yourself that everything is working properly.
+
* Finally, run your program in the <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/bin</code></span> directory. You might like to change the contents of <span style="color:#FF0000"><code>assignment0Input.txt</code></span> in the  <span style="color:#FF0000"><code>C:/DSA/assignments/assignment0/data</code></span> directory and re-run your program to convince yourself that everything is working properly.
  
  
For your first assignment, you will simply copy the <span style="color:#FF0000"><code>assignment0</code></span> directory to <span style="color:#FF0000"><code>assignment1</code></span> and follow a similar procedure, writing new assignment-specific code, of course.  There are just one thing you need to do:  edit the <span style="color:#FF0000"><code>C:DSA\assignments\assignment1\CMakeLists.txt</code></span> and change the project name from <span style="color:#FF0000"><code>assignment0</code></span> to <span style="color:#FF0000"><code>assignment1</code></span>, viz:
+
For your first assignment, you will simply copy the <span style="color:#FF0000"><code>assignment0</code></span> directory to <span style="color:#FF0000"><code>assignment1</code></span> and follow a similar procedure, writing new assignment-specific code, of course.  There are just one thing you need to do:  edit the <span style="color:#FF0000"><code>C:DSA/assignments/assignment1/CMakeLists.txt</code></span> and change the project name from <span style="color:#FF0000"><code>assignment0</code></span> to <span style="color:#FF0000"><code>assignment1</code></span>, viz:
  
 
   ##############################################
 
   ##############################################
Line 107: Line 225:
  
  
When submitting an assignment, all you have to do is submit a zipped version of your <span style="color:#FF0000"><code>myandrewid</code></span> directory with your three source code files.
+
When submitting an assignment, all you have to do is submit a zipped version of your <span style="color:#FF0000"><code>myandrewid</code></span> directory with your three source code files and your CMakelists.txt file.
  
I simply unzip it and add it to the <span style="color:#FF0000"><code>src</code></span> directory on my computer, along with the all the other students and my own solution, run CMake, launch the <span style="color:#FF0000"><code>.sln</code></span> file, compile, install, and check each executable in <span style="color:#FF0000"><code>bin</code></span> against the test data file in my <span style="color:#FF0000"><code>data</code></span> directory.  Because we build the solutions the same way, you are guaranteed that your code will compile, provided you have followed this procedure.
+
These files will be unzipped and moved it to the <span style="color:#FF0000"><code>src</code></span> directory on the marker's computer, along with the all the other students submission.  We then run CMake, launch the <span style="color:#FF0000"><code>.sln</code></span> file, compile, install, and check each executable in <span style="color:#FF0000"><code>bin</code></span> against the blind test data file in the <span style="color:#FF0000"><code>data</code></span> directory.  Because we build the solutions the same way, you are guaranteed that your code will compile, provided you have followed this procedure.
  
 
== Humour ==
 
== Humour ==
 
After all that, a little course-related humour might be welcome (if these don't make sense now, they will later).
 
After all that, a little course-related humour might be welcome (if these don't make sense now, they will later).
 +
 +
[https://xkcd.com/399/ Travelling Salesman Problem]
  
 
[http://xkcd.com/1185/ Some Ineffective Sorts]
 
[http://xkcd.com/1185/ Some Ineffective Sorts]
  
 
[https://xkcd.com/835/ Tree and Heap]
 
[https://xkcd.com/835/ Tree and Heap]
 
[https://xkcd.com/399/ Travelling Salesman Problem]
 

Latest revision as of 00:02, 23 July 2024

The following is a step-by-step guide to downloading, installing, and using the software required to submit an assignment for course 04-630 Data Structures and Algorithms for Engineers. This environment is required to ensure that software developed by students can be compiled directly by the course instructor after it has been submitted.

Follow these instructions exactly as they are stated. Do not be tempted to skip through them, assuming that you will be able to figure it out yourself. You might, but it is more likely you will miss something small but important and it won't work as required. Take your time, follow these instructions carefully, and everything will work.


Operating System

I assume you are running Windows 11.

I strongly recommend you turn off the option in the File Explorer to hide file extensions. To do this, on the File Explorer menu bar click the "..." icon and select Options > View. Make sure the tick box labelled "Hide extensions for known file types" is not ticked. If it is ticked, you will have problems identifying certain files later on (e.g. invoking the example.sln solution file to launch the Visual Studio C++ compiler). Select "Apply" after you untick the box.


C/C++ Compiler

Download Microsoft Visual Studio Community.

You can download the required installer from the Microsoft website or here.

Run the installer and follow the instructions. Be sure to install Visual Studio Community 2022.


Visual Studio Installer 01.png


Select Desktop Development with C++ and click "Install" or "Install While Downloading".


Visual Studio Installer 02.png


CMake

Download CMake binaries from here. At time of writing the latest version is 3.30.0.

You can opt for either the WIN32 installer (cmake-3.30.0-windows-x86_64.msi) or the Windows zip file. The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process). If you choose the installer option, note that if you already have CMake version 3.4 or earlier you must uninstall it first.

Here are the installation steps.


Click "Next".

CMake Installer 01.png


Click the checkbox to accept the term, and click "Next".

CMake Installer 02.png


Click the checkbox to add CMake to the PATH environment variable, and click "Next".

CMake Installer 03.png


Use the default install path, and click "Next".

CMake Installer 04.png


Click "Install".

CMake Installer 05.png


Click "Yes" to enable the files to be installed.

CMake Installer 06.png


Click "Finish".

CMake Installer 07.png


DSA Data Structures and Algorithms for Engineers Repository

Copy the DSA repository to the C: drive:

  • Download a zip archive with all the files from here.
  • Copy it to C: drive and unzip it so that you have a directory called C:/DSA.


C:/DSA has with a sub-directory structure explained in class. For our purposes here, there is an C:/DSA/assignments directory and it will contain an example C:/DSA/assignments/assignment0 sub-directory. Later on, you will generate C:/DSA/assignments/assignment1 and C:/DSA/assignments/assignment2, and so on.

There is also a C:/DSA/lectures sub-directory. This has some simple examples of standard data structures and algorithms. Later in the course, I will make available the code from the lectures, together with instructions on how to add it to the repository: the source code will go in the C:/DSA/lectures/src sub-directory and test data will go in the C:/DSA/lectures/data sub-directory.

DSA Installation 17.png

The next step is to build a Visual Studio .sln solution file so that you can compile (i.e., build) the DSA assignment0 executable. To do this, you need to run CMake against the C:DSA/assignments/assignment0 directory (where you will find the main CMakeLists.txt file). We use assignment0 because it is a dummy assignment but you will follow exactly the same procedure for all the real assignments.

Launch the CMake GUI from the Windows 11 taskbar.


DSA Installation 01.png


In the Where is the source code: type (or browse to) C:/DSA/assignments/assignment0


DSA Installation 02B.png


In the Where to build the binaries: type (or browse to) C:/DSA/assignments/assignment0/build


DSA Installation 03B.png


Select File > Delete Cache from the top menu (you must do this the first time in case there is an old invalid configuration in the DSA directory)


DSA Installation 04B.png


Click Configure


DSA Installation 05B.png


Select Visual Studio 17 20122 from the drop-down menu as the generator for the project


DSA Installation 06.png


Click Finish and watch CMake configure your project (this will take a few seconds so please be patient).


DSA Installation 07.png


The text in dialogue box will be highlighted in red, so click Configure one more time and everything should be fine.


DSA Installation 08.png


Click Generate to create the Visual Studio assignment0.sln file in the C:/DSA/assignments/assignment0/build directory.


DSA Installation 09.png


Now you are ready to launch Visual Studio and build the DSA assignment0 executable.


Go to the C:/DSA/assignments/assignment0/build directory and double-click the assignment0.sln file. This launches Microsoft Visual Studio.


DSA Installation 10.png


Select Release in the Solutions Configuration box (this is located left of centre on the toolbar and defaults to Debug).


DSA Installation 11.png


Select Build > Configuration Manager from the menu and make sure the INSTALL check-box is ticked.

Note that you will have to tick this check-box every time you rebuild the .sln solution file with CMake. If you don't do this, then your new executable won't be installed in the bin directory and you'll end up becoming very confused because none of the changes you make to your source code will be reflected in the executable you run from the bin directory (because its an old version from a previous compilation).


DSA Installation 12.png


DSA Installation 13.png


Select Build > Build Solution from the top menu.

This will compile and link the programs in the the C:/DSA/assignments/assignment0/src sub-directory and install then in the C:/DSA/assignments/assignment0/bin directory.


DSA Installation 14.png


Good! Now you are now ready to run the example dvernon.exe application that is provided with the DSA release. To do this, double click the dvernon.exe</span> executable in C:/DSA/assignments/assignment0/bin.


DSA Installation 15.png


Inspect the source code for this dummy assignment in Visual Studio.

Open exampleApplication.cpp in the Source Files folder, and read the internal documentation and the code. Do the same with exampleImplementationion.cpp.

Now open example.h in the Header Files folder and read the internal documentation and the code.


DSA Installation 16.png


Now that you understand what this program does, open assignment0Input.txt file in C:/DSA/assignments/assignment0/data and inspect its contents. After running dvernon.exe, open the assignment0Output.txt file, also in the C:/DSA/assignments/assignment0/data directory, and inspect its contents. Verify that the contents are as you expect them to be.


Finally, create your own (dummy) assignment program. To do this, follow these steps.

  • Create a directory with your Andrew Id, e.g. C:/DSA/assignments/assignment0/src/myandrewid
  • Copy the source files (.c, .cpp, .h) from the dvernon directory to the myandrewid directory.
  • Edit the C:/DSA/assignments/assignment0/src/CMakeLists.txt file and replace ADD_SUBDIRECTORY(dvernon) with ADD_SUBDIRECTORY(myandrewid), where myandrewid is your Andrew Id.
  • Edit the C:/DSA/assignments/assignment0/src/myandrewid/CMakeLists.txt file and replace dvernon with myandrewid, where myandrewid is your Andrew Id.
  • Run CMake again.
  • Re-open the assignment0.sln file (remember, it's in the C:/DSA/assignments/assignment0/build directory).
  • Your files should now be visible (and the dvernon ones will no longer be there) and you can now edit your code (change dvernon to your Andrew ID in the assignment0Application.cpp file, compile it, and install it in the bin directory by selecting Build > Build Solution from the top menu.
  • Make sure that the INSTALL check-box is ticked when you select Build > Configuration Manager from the menu to ensure that your executable is installed in the C:/DSA/assignments/assignment0/bin directory.
  • Finally, run your program in the C:/DSA/assignments/assignment0/bin directory. You might like to change the contents of assignment0Input.txt in the C:/DSA/assignments/assignment0/data directory and re-run your program to convince yourself that everything is working properly.


For your first assignment, you will simply copy the assignment0 directory to assignment1 and follow a similar procedure, writing new assignment-specific code, of course. There are just one thing you need to do: edit the C:DSA/assignments/assignment1/CMakeLists.txt and change the project name from assignment0 to assignment1, viz:

 ##############################################
 PROJECT(assignment0)
 ############################################## 

becomes

 ##############################################
 PROJECT(assignment1)
 ############################################## 


When submitting an assignment, all you have to do is submit a zipped version of your myandrewid directory with your three source code files and your CMakelists.txt file.

These files will be unzipped and moved it to the src directory on the marker's computer, along with the all the other students submission. We then run CMake, launch the .sln file, compile, install, and check each executable in bin against the blind test data file in the data directory. Because we build the solutions the same way, you are guaranteed that your code will compile, provided you have followed this procedure.

Humour

After all that, a little course-related humour might be welcome (if these don't make sense now, they will later).

Travelling Salesman Problem

Some Ineffective Sorts

Tree and Heap