Executable versions
The OpenBUGS software family is unusual in consisting of a large number of unlinked modules. These modules are linked at run time as required by the module link loader StdLoader. This loader is packed together with a few other service modules and possibly a special module Init into a small .exe or .dll / so file. These .exe and .dll / so files know nothing about the OpenBUGS software and are quite generic. The StdLoader module caues the body of a module called Init to be executed. If the module Init is not linked into the .exe file or the .dll / so StdLoader will load and link it, looking for the modules code file first in subdirectory Code and then in subdirectory System/Code. Various implementations of Init are possible giving rise to software with different functionality.
There are various ways of running the OpenBUGS software on computers with the Microsoft Windows operating system. winbugs.exe and bugs.exe are small Microsoft Windows program which loads code files (ocf) as needed. The bugs.exe program is run from the shortcut ClassicBUGS and has a similar interface to the old "ClassicBUGS" software. This shortcut sets the properties of the dos window used by the dos.exe program. A second shortcut BackBUGS runs winbugs with the file name specified on the command line, after the key word /SCRIPT, used as a source of commands in a BUGS script. This allows another program to call BUGS to do MCMC. The BackBUGS shortcut has been set up so that no window opens while BUGS runs. This can be changed by editing the shortcut so that "/HEADLESS" is removed from the command line.
brugs.dll is a small dynamic link library that can load ocf files as needed. The brugs dynamic link library was designed for use from within R and only loads ocf files that do not depend on Microsoft Windows. It is also possible to use the brugs dynamic link library from within a general C program. The pro cedures exported by the brugs library are specified in the module Bugs C.
In general the ocf files are not operating system dependent. In the make file those modules in black should be usable from both Windows and Linux, whereas the modules in red are only used in winbugs. We have produced a Linux ELF shared object file, bugs.so, equivalent of the bugs.exe file for running the BUGS software on the Linux platform. This bugs.so needs loading using dlopen from within a small C program. A second ELF shared object file brugs.so provides the R interface on Linux.
The R functions for interfacing to the brugs dynamic link library are in the BRugs package on CRAN. The names of these R functions are the same as in the OpenBUGS scripting language and have the same function. Both the scripting language and the R functions use metaprogramming to communicate with OpenBUGS, see the module BugsStdInterpreter for details.
To make the executable versions of the OpenBUGS software a linker tool is used to pack several code (ocf) files into one exe or dynamic link library (shared object file on Linux). The linker is given a list of module names (in the form subsystem prefix followed by a file name). The linker searches for the ocf file in the code subdirectory of the subsystem with the appropiate file name. Note that this ocf might correspond to a module with a name different to the name given to the linker (for example the code file the linker finds for LinConsole --Lin/Code/Console.ocf-- corresponds to a module Console and not LinConsole)
ClassicBUGS uses the Console module for input and output. There are two version of the the module Console one for the Windows platform and the other for the Linux platform. On Windows the Console module makes calls to the Windows API while on Linux it makes calls to the C runtime library. There are several versions of the Init module. The winbugs.exe program links at runtime with the version of the Init module found in the Code subdirectory if it exists otherwise it links with the version in System/Code subdirectory. For winbugs.exe to function correctly it must link with the latter Init module, that is the file Code/Init.ocf must not exist (the System/Code/Init.ocf file sets up the Windows interface for WinBUGS and also for BlackBox). The bugs.exe and bugs.so files link a version of the Init module that sets up the command line interpreter. This source code of this versions of the Init module is in Bugs/Mod/Init.odc. The source code file Init.odc in the root directory contains an empty implementation of the Init module. This empty implementation is linked into the brugs.dll and brugs.so libraries to prevent them loading the Windows interface.
To create the winbugs.exe file click in the round .blob containing an ! mark with the mouse
DevCompiler.CompileThis BugsConsole BugsConfig
DevLinker.Link
winbugs.exe := Kernel$ + Files HostFiles StdLoader Console
1 Bugslogo.ico 2 Doclogo.ico 3 SFLogo.ico 4 CFLogo.ico 5 DtyLogo.ico
6 folderimg.ico 7 openimg.ico 8 leafimg.ico
1 Move.cur 2 Copy.cur 3 Link.cur 4 Pick.cur 5 Stop.cur 6 Hand.cur 7 Table.cur
To create the classic version bugs.exe file c lick on the round blobs below containing an ! mark.
DevCompiler.CompileThis BugsConsole BugsInit
DevLinker.Link
dos bugs.exe := Kernel$+ Files HostFiles StdLoader Console Init 1 Bugslogo.ico
Finally delete the Init code file created: Code/Init.ocf.
THIS IS VERY IMPORTANT BLACKBOX / WINBUGS WILL NOT START UP IF THIS FILE EXISTS!!!
To create the brugs.dll file click in the round blob below containing a ! mark with the mouse.
DevCompiler.CompileThis BugsConsole
next open the file Init.odc in the root directory and compile it (Ctl key + k key) and then click in the round blob below containing a ! mark with the mouse.
DevLinker.LinkDynDll
brugs.dll := Kernel$+ Meta Files HostFiles StdLoader Init Console BugsInterpreter BugsC#
Finally delete the Init code file created: Code/Init.ocf.
THIS IS VERY IMPORTANT BLACKBOX / WINBUGS WILL NOT START UP IF THIS FILE EXISTS!!!
(*
Please note I am the only person who has the ELF linker at present.
*)
To create the classic version of bugs as a so file c lick on the round blobs below containing an ! mark.
DevCompiler.CompileThis LinLibc LinConsole BugsInit
DevElfLinker.LinkDynDll
bugs.so := LinKernel$+ Files LinHostFiles StdLoader Console Init
Finally delete the Init code file created: Code/Init.ocf.
THIS IS VERY IMPORTANT BLACKBOX / WINBUGS WILL NOT START UP IF THIS FILE EXISTS!!!
The small C program to load the bugs.so on Linux is here CBugs
To create an ELF version of brugs.so for Intel Linux click in the round blobs containg an ! mark with the mouse.
DevCompiler.CompileThis LinLibc LinConsole
next open the file Init.odc in the root directory and compile it (Ctl key + k key) and then click in the round blob below containing a ! mark with the mouse.
DevElfLinker.LinkDynDll
brugs.so := LinKernel$+ Files LinHostFiles StdLoader Meta Init Console BugsInterpreter BugsC#
Finally delete the Init code file created: Code/Init.ocf.
THIS IS VERY IMPORTANT BLACKBOX / WINBUGS WILL NOT START UP IF THIS FILE EXISTS!!!