200 likes | 366 Views
CSCI N305 C Language Programming. Welcome to CSCI N305! Compiling Your First Program Using Microsoft Visual Studio 2008. Objectives for the Lab. Learn the difference between client-side and server-side programming Learn how to open an empty solution and project under Visual Studio .Net
E N D
CSCI N305C Language Programming Welcome to CSCI N305! Compiling Your First Program Using Microsoft Visual Studio 2008
Objectives for the Lab • Learn the difference between client-side and server-side programming • Learn how to open an empty solution and project under Visual Studio .Net • Compile and run a simple program
Client-side vs Server-side compiling • Environment setup • Install MS VS .Net 2008 from iuware.iu.edu • Client-side compiling runs locally on your computer • Requires installation of a compiler on your system • Consumes local CPU and hard disk space • No network (internet) connectivity required • Service-side compiling runs remotely on a server • Requires remote access software such as SSH available from iuware.iu.edu • Server is typically more powerful CPU and has more storage. • Typically used for larger projects • Easier to implement team development environment • Normally uses a command line interface rather than graphical • Network (internet) connectivity required • Used for business applications that require production infrastructure (production monitoring, nightly backups, etc.)
Start Microsoft Visual Studio 2008 • Start → All Programs → Microsoft Visual Studio 2008 → Microsoft Visual Studio 2008
Starting for the first time • The first time you run MSVS, you might get a window like this. • Set Visual C++ Development Setting as your default environmental settings. • Use General Development Settings if you have no preference.
Initial MSVS Window • Here is an image of the initial window.
Opening a New Project • Open a project using File → New Project → Visual C++ → Win32 → Win32 Console Application → enter your project name and browse to select a location (where your project will be saved) → OK.
Project Settings • Choose Next > at this dialog.
Project Settings (continued) • Be sure to check Empty project and Finish.
Add a New Item • Right-click on Source Files and Add a New Item.
Create a .c File • Choose Visual C++ Code, C++ File, enter a file name with .c as the file extension.
Enter Code into Your File • Enter a standard C program into the .c file.
Save and Compile Your Program • Save → Build → Build Solution
Save and Compile Your Program • A successful build:
Save and Compile Your Program • An unsuccessful build, read the error message and correct the errors and build again:
Run the Program • After a successful build, Debug →Start Without Debugging to run the program:
Run the Program • Examine the output:
Congratulations! • You created a new Microsoft Visual Studio 2008 Project. • Selected Visual C++ Win32 Console Application. • Created your own .c file, entering code just like in class. • Ran your program to produce output. • You did all of this using an easy editor without logging onto the internet.
Open an Existing Program If your project is named projectOne: • Find the projectOne folder at the location where you saved your project. • In the projectOne folder, double click on the file projectOne.vcproj, or projectOne.sln. • Double click on the .c file (e.g. main.c) will only open up the code file. It will not let you compile or run the program using Visual Studio 2008.
Submit a Program You only need to submit the .c file.