Recipe 1.2. Building a Simple "Hello, World" Application
from the Command Line
Problem
You want to build a simple "Hello, World" program, such as that in Example 1-4
.
Example 1-4. A simple "Hello, World" program
hello.cpp
#include <iostream>
int main( )
{
std::cout << "Hello, World!\n";
}
Solution
Follow these steps:
1.
1.  Set any environment variables required by your toolset.
2.
2. Enter a command telling your compiler to compile and link your program.
Scripts for setting environment variables are listed in Table 1-5
; these scripts are located in the same
directory as your command-line tools (Table 1-3
). If your toolset does not appear in Table 1-5
, you can
skip the first step. Otherwise, run the appropriate script from the command line, if you are using
Windows, or source the script, if you are using Unix.
Table 1-5. Scripts for setting environment variables required by your command-line tools
Toolset
Script
Visual C++
vcvars32.bat
Intel (Windows)
iclvars.bat[2]
Intel (Linux)
iccvars.sh or iccvars.csh
Metrowerks (Mac OS X)
mwvars.sh or mwvars.csh[3]
Metrowerks (Windows)
cwenv.bat
Comeau
Same as the backend toolset
[2] With earlier version of the Intel compiler, this script was named iccvars.bat.
Page 31
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
Pdf format specification - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
break pdf into multiple files; break a pdf
Pdf format specification - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
split pdf by bookmark; c# split pdf
Page 32
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
TIFF Image Viewer| What is TIFF
The TIFF specification contains two parts: Baseline TIFF (the edit and processing images with TIFF format and other such as Bitmap, Png, Gif, Tiff, PDF, MS-Word
pdf file specification; pdf no pages selected
DocImage SDK for .NET: Web Document Image Viewer Online Demo
Microsoft PowerPoint: PPTX, PPS, PPSX; PDF: Portable Document Format; TIFF: Tagged Image File Format; XPS: XML Paper Specification. Supported Browers: IE9+;
reader split pdf; pdf will no pages selected
Page 33
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
GIF Image Viewer| What is GIF
routines according to the latest GIF specification to meet edit and processing images with Gif format and other such as Bitmap, Png, Gif, Tiff, PDF, MS-Word
cannot select text in pdf; acrobat split pdf pages
C# Imaging - C# Code 128 Generation Guide
minimum left and right margins that go with specification. load a program with an incorrect format", please check Create Code 128 on PDF, Multi-Page TIFF, Word
pdf specification; break up pdf into individual pages
Recipe 1.3. Building a Static Library from the Command
Line
Problem
You wish to use your command-line tools to build a static library from a collection of C++ source files,
such as those listed in Example 1-1
.
Solution
First, use your compiler to compile the source files into object files. If your source files include headers
located in other directories, you may need to use the -I option to instruct your compiler where to search
for headers; for more information, see Recipe 1.5
. Second, use your archiver to combine the object files
into a static library.
To compile each of the three source files from Example 1-1
, use the command lines listed in Table 1-8
,
modifying the names of the input and output files as needed. To combine the resulting object files into a
static library, use the commands listed in Table 1-10
.
Table 1-10. Commands for creating the archive libjohnpaul.lib or libjohnpaul.a
Toolset
Command line
GCC (Unix)Intel (Linux)Comeau (Unix)
ar ru libjohnpaul.a john.o paul.o
johnpaul.oranlib libjohnpaul.a
GCC (Windows)
ar ru libjohnpaul.a john.o paul.o johnpaul.o
Visual C++Comeau (with Visual C++)
lib -nologo -out:libjohnpaul.lib john.obj
paul.obj johnpaul.obj
Intel (Windows)
xilib -nologo /out:libjohnpaul.lib john.obj
paul.obj johnpaul.obj
Metrowerks (Windows)
mwld -library -o libjohnpaul.lib john.obj
paul.obj johnpaul.obj
Metrowerks (Mac OS X)
mwld -library -o libjohnpaul.a john.o paul.o
johnpaul.o
Borland
tlib libjohnpaul.lib /u /a /C +john +paul
+johnpaul
Digital Mars
lib -c -n libjohnpaul.lib john.obj paul.obj
johnpaul.obj
For example, to compile john.cpppaul.cpp, and johnpaul.cpp into object files using GCC, change to
the directory johnpaul and enter the following commands to produce the object files john.opaul.o,
Page 34
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
VB Imaging - EAN-8 Generating Tutorial
compatible with the latest GS1 General Specification, with the Besides the PNG image format, other supported common 8 on defined page area of a PDF, multi-page
pdf link to specific page; pdf split file
VB.NET Image: Create Code 11 Barcode on Picture & Document Using
REFile.SaveDocumentFile(doc, "c:/code11.pdf", New PDFEncoder()). Data, Valid: 0-9, -, Format, PNG GIF JPEG. to the ISO/IEC international specification, the minimum
break pdf into single pages; break pdf
Page 35
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
C# Imaging - QR Code Image Generation Tutorial
to draw, insert QR Codes in PDF, TIFF, MS C# code to adjust bar code image format, location, resolution ISO+IEC+18004 QR Code bar code symbology specification.
add page break to pdf; break pdf file into parts
C# Imaging - EAN-8 Generating Tutorial
compatible with the latest GS1 General Specification, with the Besides the PNG image format, other supported common 8 on defined page area of a PDF, multi-page
break pdf documents; break pdf file into multiple files
Page 36
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
VB Imaging - Micro PDF 417 VB Barcode Generation
with established ISO/IEC barcode specification and standard You can easily generator Micro PDF 417 barcode and a program with an incorrect format", please check
break a pdf file into parts; split pdf into multiple files
GS1-128 C#.NET Integration Tutoria
by GS1 in its system standards using Code 128 barcode specification. text //Generate EAN 128 barcodes in GIF image format ean128.generateBarcodeToImageFile
pdf insert page break; break pdf into separate pages
Recipe 1.4. Building a Dynamic Library from the Command
Line
Problem
You wish to use your command-line tools to build a dynamic library from a collection of C++ source
files, such as those listed in Example 1-2
.
Solution
Follow these steps:
1.
1.  Use your compiler to compile the source files into object files. If you're using Windows, use the 
-D option to define any macros necessary to ensure that your dynamic library's symbols will be
exported. For example, to build the dynamic library in Example 1-2
, you need to define the
macro GEORGERINGO_DLL. If you're building a third-party library, the installation instructions
should tell you what macros to define.
2.
2. Use your linker to create a dynamic library from the object files created in step 1.
If your dynamic library depends on other libraries, you'll need to tell the
compiler where to search for the library headers, and to tell the linker the names
of the other libraries and where to find them. This is discussed in detail in Recipe
1.5
.
The basic commands for performing the first step are given Table 1-8
; you'll need to modify the names
of the input and output files appropriately. The commands for performing the second step are given in 
Table 1-11
. If you're using a toolset that comes with static and dynamic variants of its runtime libraries,
direct the compiler and linker to use a dynamically linked runtime, as described in Recipe 1.23
.
Table 1-11. Commands for creating the dynamic library libgeorgeringo.so, libgeorgeringo.dll, or
libgeorgeringo.dylib
Toolset
Command line
GCC
g++ -shared -fPIC -o libgeorgeringo.so
george.o ringo.o georgeringo.o
GCC (Mac OS X)
g++ -dynamiclib -fPIC -o libgeorgeringo.dylib
george.o ringo.o georgeringo.o
GCC (Cygwin)
g++ -shared -o libgeorgeringo.dll
-Wl,out-implib,libgeorgeringo.dll.a-W1,export-
all-symbols -Wl,enable-auto-image-base
george.o ringo.o georgeringo.o
Page 37
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
Page 38
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
Page 39
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
Recipe 1.5. Building a Complex Application from the
Command Line
Problem
You wish to use your command-line tools to build an executable that depends on several static and
dynamic libraries.
Solution
Start by building the static and dynamic libraries on which your application depends. Follow the
instructions distributed with the libraries, if they are from a third party; otherwise, build them as described
in Recipe 1.3
and Recipe 1.4
.
Next, compile your application's .cpp files into object files as described in "Building a Simple "Hello,
World" Program from the Command Line. You may need to use the -I option to tell your compiler where
to search for the headers needed by your application, as shown in Table 1-12
.
Table 1-12. Specifying directories to search for headers
Toolset
Option
All
-I<directory>
Finally, use your linker to produce an executable from the collection of object files and libraries. For
each library, you must either provide a full pathname or tell the linker where to search for it.
At each stage of this process, if you are using a toolset which comes with static and dynamic variants of
its runtime libraries, and if your program uses at least one dynamic library, you should direct the compiler
or linker to use a dynamically linked runtime library, as described in Recipe 1.23
.
Table 1-13
presents commands for linking the application hellobeatles from Example 1-3
. It assumes
that:
The current directory is hellobeatles.
The static library libjohnpaul.lib or libjohnpaul.a was created in the directory johnpaul.
The dynamic library georgeringo.dll, georgeringo.so, or georgeringo.dylib and its import
library, if any, were created in the directory georgeringo.
Since Comeau can't build dynamic libraries, as mentioned in Recipe 1.4
, the
entry for Comeau in Table 1-13
assumes that libgeorgeringo has been built as a
static library rather than as a dynamic library. To build libgeorgeringo as a static
library, remove the modifier GEORGERINGO_DECL from the declaration of
the function georgeringo( ) in Example 1-2
.
Page 40
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html
Documents you may be interested
Documents you may be interested