Integrating Thread-- into projects

Thread-- consists entirely of declaration files, so if you want to use Thread-- in you projects, you can just copy the headers into your projects source tree and read below for a few more issues. (However, read Copyright of the source code., and make sure you understand the terms of how you can do that).

Autotools Based Projects

The easiest way is to use the provided aclocal macro file threadmm.m4. In this file, the macro AM_PATH_THREADMM that you can use in your configure.ac file. This will define the substitution variable THREADMM_CPPFLAGS to contain the path to the Thread-- headers, and THREADMM_LIBS to contain the libraries of the backend. Put that macro in your configuration file.

    ...
    AM_PATH_THREADMM
    ...

And in your Makefile.am

    ... 
    AM_CPPFLAGS = $(THREADMM_CPPFLAGS)
    AM_LDFLAGS  = $(THREADMM_LIBS)
    ...

Selecting the Backend to Use

Ofcourse, if you copy the headers to your project, you know where the headers are, and so you don't need to get the inclussion path for the headers. However, you still need to figure out what bakend will be used on the targe system. If you're only compiling for one thread model (say POSIX threads), then you can probably do away with defining the preprocessor macros THREADMM_POSIX, THREADMM_CTHREADS, and/or THREADMM_WIN32. However, if you do not know a priori what thread library is available on the target system, you need to do some sort of test to see what is available.

The file threadmm.m4 also defines the macro THREADMM_MODELS which will check for available thread library models. Use that in your configuration file like

    ...
    THREADMM_MODELS
    ...

This macro will define the preprocessor macro THREADMM_POSIX if a POSIX backend is used, THREADMM_CTHREADS if CThreads are available, and/or THREADMM_WIN32 if 32bit Windows threads are available.

Note:
For the POSIX backend, the macro actually tests whether optional features are available, and if so, it will enable them. If you do not use the macro THREADMM_MODELS you need to make some equivilant tests, or you will only be able to use the most basic features of the POSIX thread library. Please look in the files in the directory threadmm/posix for just what preprocessor macros is used.
Remember, you also need to link your application to the appropriate thread library. The macro THREADMM_MODELS tries to figure that out for you, but if you don't use that macro, you need to figure it out yourself.
Top of page
Last update Tue Nov 9 12:40:50 2004
Christian Holm
Created by DoxyGen 1.3.9.1