Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |
Please note that the ZThread library is an independent
project and is not supported by the authors of this book; we are simply using
the library in this chapter and cannot provide technical support for
installation issues. See the ZThread web site for installation support and
error reports.
The ZThread library is distributed as source code. After
downloading it (version 2.3 or greater) from the ZThread web site, you must
first compile the library, and then configure your project to use the library.
The preferred method for compiling ZThreads for most flavors
of UNIX (Linux, SunOS, Cygwin, etc.) is to use the configure script. After unpacking
the files (using tar), simply execute:
./configure && make
install
from the main directory of the ZThreads archive to compile
and install a copy of the library in the /usr/local directory. You can
customize a number of options when using this script, including the locations
of files. For details, use this command:
The ZThreads code is structured to simplify compilation for
other platforms and compilers (such as Borland, Microsoft, and Metrowerks). To
do this, create a new project and add all the .cxx files in the src
directory of the ZThreads archive to the list of files to be compiled. Also, be
sure to include the include directory of the archive in the header
search path for your project. The exact details will vary from compiler to
compiler so you ll need to be somewhat familiar with your toolset to be able to
use this option.
Once the compilation has succeeded, the next step is to
create a project that uses the newly compiled library. First, let the compiler
know where the headers are located so that your #include statements will
work properly. Typically, you will add an option such as the following to your
project:
-I/path/to/installation/include
If you used the configure script, the installation
path will be whatever you selected for the prefix (which defaults to /usr/local).
If you used one of the project files in the build directory, the
installation path would simply be the path to the main directory of the
ZThreads archive.
Next, you ll need to add an option to your project that will
let the linker know where to find the library. If you used the configure
script, this will look like:
-L/path/to/installation/lib
lZThread
If you used one of the project files provided, this will
look like:
-L/path/to/installation/Debug
ZThread.lib
Again, if you used the configure script, the
installation path will be whatever you selected for the prefix. If you used a
provided project file, the path will be the path to the main directory of the
ZThreads archive.
Note that if you re using Linux, or if you are using Cygwin (www.cygwin.com) under Windows, you may not need to modify your
include or library path; the installation process and defaults will often take
care of everything for you.
Under Linux, you will probably need to add the following to
your .bashrc so that the runtime system can find the shared library file
LibZThread-x.x.so.O when it executes the programs in this chapter:
export
LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
(Assuming you used the default installation process and the
shared library ended up in /user/local/lib; otherwise, change the path to your
location).
Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |