C++


First ;

Second


Third


Four


Five


Six


Seven


Eight


Nine






 How to ;

  a.  Compilation process.

The C++ compilation process

C++ compilation process
Compiling a source code file in C++ is a four-step process. For example, if you have a C++ source code file named prog1.cpp and you execute the compile command
   g++ -Wall -ansi -o prog1 prog1.cpp
the compilation process looks like this:
  1. The C++ preprocessor copies the contents of the included header files into the source code file, generates macro code, and replaces symbolic constants defined using#define with their values.
  2. The expanded source code file produced by the C++ preprocessor is compiled into the assembly language for the platform.
  3. The assembler code generated by the compiler is assembled into the object code for the platform.
  4. The object code file generated by the assembler is linked together with the object code files for any library functions used to produce an executable file.
By using appropriate compiler options, we can stop this process at any stage.
  1. To stop the process after the preprocessor step, you can use the -E option:
       g++ -E prog1.cpp
    
    The expanded source code file will be printed on standard output (the screen by default); you can redirect the output to a file if you wish. Note that the expanded source code file is often incredibly large - a 20 line source code file can easily produce an expanded file of 20,000 lines or more, depending on which header files were included.
  2. To stop the process after the compile step, you can use the -S option:
       g++ -Wall -ansi -S prog1.cpp
    
    By default, the assembler code for a source file named filename.cpp will be placed in a file named filename.s.
  3. To stop the process after the assembly step, you can use the -c option:
       g++ -Wall -ansi -c prog1.cpp

  b. Execute  the program.

How to compile & run Project 1 using Visual C++

Thanks to Jeff Cousens, the Library PC Lab manager, here are some instructions to help you compile and run project 1 using Visual C++.
Uncompressed proj1.tar.gz to C:\Work, creating C:\Work\Proj1 containing your project files
Started VC++ (Start -> Programs -> Programming -> Microsoft Visual C++)
Created a new project (File -> New, select the project tab, clicked on Win32 Console Application, Project name: Proj1, Location: C:\Work, empty project on the next tab)
Added files to the project (in the workspace window to the left, select the FileView tab on the bottom, right click on Source Files and Add Files to Folder and add your 3 .c files then right click on Header Files and Add Files to Folder, adding your 2 .h files)
Edited lowlevel.c to change:
#include < string.h >
#include < GL/gl.h >
to:
#include < string.h >
#include < windows.h >
#include < GL/gl.h >
Note: due to HTML formating, I had to put in spaces.. you should not have spaces between the greater-than and less-than signs in your include statements
For some reason gl.h causes a large number of errors without windows.h (102 to be exact - probably b/c it's Microsoft's gl.h). You can edit the file in Visual Studio by expanding Source Files in the workspace window and double-clicking on lowlevel.c.

Built/executed the project (Built -> Build or Execute Proj1.exe, F7 to build, ctrl+F5 to execute or click the Build or Execute button on the Build MiniBar).
Other possible problems you may encounter:
If this doesn't work on your home machine, you need to make sure you have the windows source for GLUT (and possibly later GLUI) (Standard libraries should include the other OpenGL source, but may not)
The following solution is thanks to John Glassmire:

The following .h and .lib files are necessary for compiling your code with Visual C++. The .dll is necessary in your windows environment to execute the code.
glut32.dll
glui.h
glut.h
glui32.lib
glut32.lib
Adding the following files got the program compiling on my home computer (they are already on the PC lab comps.)
.h files in  Visual Studio\vc98\include\gl\
.lib files in  Visual Studio\vc98\lib\
.dll in C:\windows\system32\


Conclusion ;
In the microsoft c++ , i have learn how to compilation process and how to execute the program .

No comments:

Post a Comment