C++ basic for Build and Release Engineers

The compiler
Compiler is the software that translates the syntactically correct statements of a program into objectcode or can also produce an executable using a linker and the object code produced. An object codecan’t be run directly on a machine since it contains information about the object module in addition tothe machine instructions.

The linker
A linker is another program which is invoked upon compiled object files. A linker just identifies thestructure of the object files, resolves the functions and object linkages and creates an executable

To understand linkers, it helps to first understand what happens “under the hood” when you convert a source file (such as a C or C++ file) into an executable file (a file that can be executed on your machine or someone else’s machine running the same architecture).

Under the hood, when a program is compiled, the compiler converts the source file into object byte code. This byte code (sometimes called object code) is mnemonic instructions that only your computer architecture understands. Traditionally, these files have an .OBJ extension.

After the object file is created, the linker comes into play. More often then not, a real program that does anything useful will need to reference other files. In C, for example, a simple program to print your name to the screen would consist of:
printf(“Hello Nick!\n”);

When the compiler compiled your program into an obj file, it simply put a reference to the printf function. The linker resolves this reference. Most programming languages have a standard library of routines to cover the basic stuff expected from that language. The linker links your OBJ file with this standard library. The linker can also link your OBJ file with other OBJ files. You can create other OBJ files that have functions that can be called by another OBJ file. The linker works, almost like a word processor’s copy and paste. It “copies” out all the necessary functions your program references and creates a single executable. Sometimes other libraries that are copied out are dependent on yet other OBJ or library files. Sometimes a linker has to get pretty recursive to do its job.

Note that not all operating systems create a single executable. Windows, for example, uses DLL’s that keep all these functions together in a single file. This reduces the size of your executable, but makes your executable dependant on these specific DLLs. DOS used to use things called Overlays (.OVL files). This had many purposes, but one was to keep commonly used functions together in 1 file (another purpose it served, in case you’re wondering, was to be able to fit large programs into memory. DOS has a limitation in memory and overlays could be “unloaded” from memory and other overlays could be “loaded” on top of that memory, hence the name, “overlays”). Linux has shared libraries, which is basically the same idea as DLL’s (hard core linux guys I know would tell me there are MANY BIG differences).

The procedure for compiling a C++ program is the same as for a C program, but uses the command g++ instead of gcc. Both compilers are part of the GNU Compiler Collection.

Sample C++ Program 1

#include <iostream>
int main()
using namespace std;
cout << “Hello world!” << endl;
return 0;

The program can be compiled with the following command line:
g++ -Wall hello.cc -o hello

The resulting executable can be run in exactly same way as the C version, simply by typing its filename:
$ ./hello Hello, world!

Sample C++ Program 2

#include <iostream>
#include <cmath>

using namespace std;

int main()
int x = 0;
while(x < 10) {
double y = sqrt((double)x);
cout << “The square root of ” << x << ” is ” << y << endl;
return 0;

Building on the Command Line

Use the compiler (cl.exe) to compile and link source code files.

The compilers produce Common Object File Format (COFF) object (.obj) files. The linker produces executable (.exe) files or dynamic-link libraries (DLLs).

Use the linker (link.exe) to link compiled object files.

MSBuild (Visual C++)
Use MSBuild to build Visual C++ projects and Visual Studio solutions from the command line. Invoking this utility is equivalent to running the Build project or Build Solution command in the Visual Studio integrated development environment.

The build process is controlled by the information in a project file (.vcxproj) that you can create and edit. The project file specifies build options based on build stages, conditions, and events.

Use DEVENV combined with a command line switch, such as /Build or /Clean, to perform certain build commands without displaying the Visual Studio IDE.

Devenv lets you set various options for the integrated development environment (IDE), and also build, debug, and deploy projects, from the command line. Use these switches to run the IDE from a script or a .bat file, for example, a nightly build script, or to start the IDE in a particular configuration.
For example, the command devenv /build myproject1.vbproj

Use NMake to automate tasks that build Visual C++ projects. The Microsoft Program Maintenance Utility (NMAKE.EXE) is a tool that builds projects based on commands contained in a description file.


Header file vs Library

Generally, a header file notifies the compiler of certain things (mostly their existence or declarations) so that the compiler can correctly build a single translation unit (such as a single C file).

A library file is the actual executable code that does the work as specified in that header file. This is linked in by the linker to provide the actual functionality (the _definitions rather than just the declarations).

Header Files: These are the files that are included at the top of any program. If we use any function inside a program, then the header file containing declaration or definition of that function ,has to be included.Like printf() is defined in stdio.h.So, we must include it (by #include in order to use printf().

Library Files: These are the files which the compiler uses in order to define the functions which have been used in the program and had been declared inside the header file.Like, printf() has its complete definition ,like how it will work etc. in an I/O library! So, the compiler uses that library to get the machine code for printf.

Header files are TEXT files while library files are BINARY. This means, we can read and modify the header file but not the library!
Header file is in C language while the library is in machine language!
Header file has to be included by the programmer while the compiler automatically relates the library file(s) with the program!

Tagged : / / / / / / / /

Differentiating between COM & C++ dlls from installerdatabase (.msi)

InstallerExpert created the topic: differentiating between COM & C++ dlls from installerdatabase (.msi)

Is there a way that I could differentiate between COM & C++ DLL by looking into the installer database file (.msi), I know that all .NET components are maintained in msiAssembly table but I think both COM & C++ files are maintained under Files table, is there a way by looking into some attributes in the table that I can know if that is of type C++ DLL or COM component.

Tagged :

Multi-process C# app like Google Chrome

InstallerExpert created the topic: Multi-process C# app like Google Chrome
2 months ago we released wyBuild & wyUpdate v2.5. This release adds a free automatic updater control for C# & VB.NET apps. And because we wanted to keep things simple we left the wyUpdate.exe to do all the hard work (checking, download, installing) in the background while the AutomaticUpdater control is visible on your app’s main form.

Tagged :

Any Possible Software/Plugin FoR SCM Workflow

pankaj2252369@gmail.com created the topic: Any possible Software/plugin for SCM workflow?
Hey Team, Thanks for lot of information on the site. wonderful work.

Any idea on SCM workflow software/framework ? which would help me to complete the SDLC lifecycle.

For E.g: When ever developers are done with their changes/check-ins, they would request CM team to build (via Email), And when CM builds and deploy , they will email to Testing Team, finally when its been tested they will let CM/RM team inform about the bugs, etc. finally product will be released.

All this was happening manually(via emails). If we have a workflow software, so that we can have everything in process oriented and SCM would be very easy.

Any Suggestion are welcome.

If know of any plug-ins , we can extend our programs to make it work to our systems.

Thanks in Advance!

rajeshkumar replied the topic: Re: Any possible Software/plugin for SCM workflow?
I would suggest following in Commercial | Opensource:-
SCM Workflow consisit of following..
SCM Tools |Scripting |Build / WorkFlow Mgmt Tools |
| Release / Dep Tools | Security | Testing Tools |
Test Coverage | Source-code Analysis | Issue Tracking Tools | IDEs Integration |Virtualization |

Please find list of tools and find you combination based in your project requirement and budget

Build / WorkFlow Mgmt Tools

Apache Continuum
OpenMake Meister
Team Foundation Server
Electric Cloud

SCM Tools

CA Harvest
MKS Source Integrity
Team Foundation Server


Shell Scripts
Perl Scripts
Visual Studio

Release / Dep Tools
Rational Team Concert


Active Directory
Single Sign-on

Testing Tools

Source-code Analysis


Issue Tracking Tools

HP Quality Center
PVCS Tracker
Team Foundation Server

IDEs Integration

Visual Studio


VMWare Lab Manager
Amazon (Elastic Cloud)
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

pankaj2252369@gmail.com replied the topic: Re: Any possible Software/plugin for SCM workflow?
Thanks for the response. But this i snot actually i am looking for.. I have idea on the mentioned tools. But wanted to create one separate tool for our internal purpose. So i am just checking, if there are any SCM related plugins /frame works in market, So that i do not spend more time on the things that are available.

Anyways.. Thank you so much!

rajeshkumar replied the topic: Re: Any possible Software/plugin for SCM workflow?
Hi John,

May be i am getting confused from you questions. Framework which can help you to develop your internal tools????

You mean you would like to develop your own tools, Then you might want to identify the technology first using which you want your development work get started. There are plenty of framework in Java| C++ | Perl | Pythin| Php | Ruby on rails etc
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged : / / / / /