14: Projects and Other Topics

What We Will Cover


Continuations

Questions from last class?

Project Questions?

STEM Counselor Survey

Final Exam Approaching

  • Final Examinations Schedule
  • Final exams must be taken at the scheduled time
  • If you need the proctoring center, schedule it two weeks early

14.1: Running Under Windows

Learner Outcomes

At the end of the lesson the student will be able to:

  • Run console programs under Windows

14.1.1: About DLL's

  • We can run our compiled programs under Windows, on computers without Cygwin installed
  • To accomplish this, we need to include the appropriate Cygwin DLL's
  • DLL stands for Dynamic Link Library
  • A DLL is a binary file that provides a library of functions for use by Windows applications
  • All programs running under Windows use DLL's
  • Any DLL that a program uses must be available on the computer where the application is running

Cygwin DLL's

  • Cygwin provides a number of DLL's
  • These DLL's are located in the cygwin/bin directory
  • They are easy to identify because they have an extension of .dll and type Application Extension
  • Your programs uses one or more of these DLL's when they run
  • Any DLL that your program uses must be accessible to the program
  • Thus, to run your program on a computer without Cygwin installed, we need to include a copy of the needed Cygwin DLL's

14.1.2: Finding the DLL's We Need

  • The easiest way to find the DLL's your program needs is to run the program under Windows
  • Whenever the program needs a DLL, it attempts to load the DLL
  • When it cannot load the DLL, it fails and identifies the DLL it needs

need dll message

  • To fix the problem, we copy the needed DLL into the same directory as your application
  • Since the computers in our classroom have paths set to the Cygwin\bin directory, we need to delete the path setting for this test:
    path=.

Example of Finding Needed DLL's

  • We want to run the playagain.cpp program under Windows
  • We save the program to the desktop and compile it using TextPad
  • Next we launch a Windows console:
    1. From the Start menu, Select Run...
    2. In the text box type cmd and press the Enter key
  • Then we remove the path to cygwin\bin by typing:
    path=.
  • Now when we try to run the program, we get an error message
  • We locate the Cygwin DLL we need in the cygwin\bin directory and copy it to the desktop
  • Now we can successfully run the application

Example Application

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main() {
    char repeat = 'y';
    while ('y' == repeat) {
        cout << "\nPlaying an exciting game!\n";
        cout << "Do you want to play again? (y/n) ";
        cin >> repeat;
    }
    cout << "\nThanks for playing!\n";

    return 0;
}

Exercise 14.1: Running on Windows without Cygwin (5m)

In this exercise we run a program under Windows without starting Cygwin or using TextPad.

Specifications

  1. Choose an application, compile it, and copy the .exe file to the desktop
  2. Open a Window's terminal window:
    1. Click the Start button
    2. Select "Run..."
    3. In the Open box type in: cmd
    4. Press the Enter key
  3. Change to the Desktop directory:
    cd Desktop
    
  4. Set the path on the computer to '.':
    path=.
  5. Run the .exe file and find the missing DLL's

    To run in the Windows terminal, type the program name (no ./ needed).

  6. Copy the missing DLL's to the Desktop and run again

14.1.3: Summary

  • We can run C++ programs compiled in Cygwin on Windows computers without Cygwin installed
  • To make your programs work, we need to include any required DLL's
    • This is true for any Windows application
  • The easiest way to find the needed DLL is to run your program in the Windows terminal
  • When your program needs a DLL, Windows will try to load it
  • When Windows cannot load the DLL, it gives an error message identifying the missing DLL
  • To fix the problem, we copy the DLL into the directory in which we put your .exe file

Check Yourself

  1. What is a DLL?
  2. Why do your programs need DLL's?
  3. How can you add the DLL's needed to make your program run?

14.2: Project Design and Prototype Review

Learner Outcomes

At the end of the lesson the student will be able to:

  • Review feedback on your project design and prototype

Instructions

  1. Load your project prototype onto your computer
  2. Have a paper copy of your design available for review
  3. Be prepared for the instructor to review your project prototype

Wrap Up

Due Next:
A14-Sampler Project (12/5/19)
When class is over, please shut down your classroom computer.
Work on your project!
Last Updated: November 26 2019 @17:02:52