next up previous
Next: 5 Threaded I/O shutdown Up: The OMNI Thread Abstraction Previous: 3 Thread object

4 Using threads in OMNI programs

All you need to do is include the omnithread.h header file in your source code, and then link in the omnithread library in to your executable. The details of what you need to put in your dir.mk to make the header files and library available is best explained by example. You just need something like this:

CXXSRCS = wob.cc

CPPFLAGS = $(OMNITHREAD_CPPFLAGS)

wob = $(patsubst %,$(BinPattern),wob)

$(wob): wob.o $(OMNITHREAD_LIB_DEPEND)
        @(libs="$(OMNITHREAD_LIB)"; $(CXXExecutable))

Note that if you use CORBA then it is important that $(CORBA_LIB) appears before $(OMNITHREAD_LIB) in the libs="..." assignment. This is because linking the Solaris thread library before the Orbix library results in a binary which segmentation faults inside the Orbix library initialisation.



David Riddoch
Tue Jun 8 10:48:20 BST 1999