[linking0]     Executable versions and
               linking



The OpenBUGS software family is unusual in consisting of a large number of unlinked modules in a binary format .These modules can not be directly accessed by the operating system. A linker tool is used to link a number of binary modules into either an executable or a library. The BlackBox developement tools contain a special module the StdLoader which is able to load and link new modules into a running OpenBUGS application. There are two approaches to packageing the OpenBUGS software. In the first only a small number of modules are linked along with StdLoader in the second all the modules in the OpenBUGS software are linked into one large file. The first approach is more dynamic and flexible and is used in the Windows version of OpenBUGS. However it has some disadvantages: it involves a large number of files in a particular directory structure which can become fragile when used with a library for interfacing to other software. For this reason we prefer to fully link the library versions of OpenBUGS.

There are various ways of running the OpenBUGS software on computers with the Microsoft Windows operating system. OpenBUGS.exe is small Microsoft Windows program which loads code files (ocf) as needed. The classicbugs.exe program has a similar interface to the old "ClassicBUGS" software. A shortcut BackBUGS runs OpenBUGS with the file name specified on the command line, after the key word /PAR, used as a source of commands in a OpenBUGS script. This allows another program to call OpenBUGS to do MCMC simulation. The BackBUGS shortcut has been set up so that no window opens while OpenBUGS runs. This can be changed by editing the shortcut so that "/HEADLESS" is removed from the command line.

The OpenBUGS dynamic link library was designed for use from within Splus/R statistical programming enviroment and only uses modues that do not depend on Microsoft Windows. The pro
cedures exported by the brugs library are specified in the module BugsBRugs . In particular the CLI procedure sets up a simple command line interpreter -- the ClassicBUGS interface. It is also possible to use the dynamic link library from within a general C program (see
BRugs header file for details).

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 under Windows. With just a few changes the modules that are linked to form the Windows dynamic link library can also be linked to produce a shared object file for Linux.

The R functions for interfacing to the dynamic link library / shared object file 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. Winows and Linux use different binary formats for executables and libraries. Therefore two linker tools are required: DevLinker for Windows and DevElfLinker for Linux.



How to link OpenBUGS

To create the OpenBUGS.exe file click in the round .blob containing an ! mark with the mouse

[linking1]DevLinker.Link
OpenBUGS.exe := Kernel$ + Files HostFiles HostPackedFiles StdLoader
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 [linking2]

Bind licence file, menu files and about box into executable.
[linking3] DevPacker.PackThis OpenBUGS.exe :=
gpl-3.0.txt
Bugs/Rsrc/Menus.odc
Doodle/Rsrc/Menus.odc
Maps/Rsrc/Menus.odc
Rsrc/Menus.odc => System/Rsrc/Menus.odc
Rsrc/About.odc => System/Rsrc/About.odc[linking4]

To make a fully linked version of the dynamic link library for Windows click in the round blob below. To make a library that does not use the taucs sparse matrix code remove the module MathTaucsImp from the list of linked modules.

[linking5]DevLinker.LinkDll
libOpenBUGS.dll := Kernel$+ Files HostFiles
Meta Console Math Strings Dialog Stores
Services

WinConsole BugsInterpreter

BugsMappers BugsStrings BugsFiles BugsStdInterpreter
BugsMsg BugsRegistry

MathSort MathMatrix
MathSparsematrix
MathFunc MathRandnum MathODE MathFunctional MathRungeKutta45
MathAESolver MathIntegrate
MathLincon MathTT800 MathDiagmatrix MathBGR MathSmooth

GraphRules GraphNodes GraphLogical GraphStochastic GraphScalar GraphVector
GraphLimits GraphUnivariate GraphMultivariate GraphConjugateMV GraphChain GraphGMRF
GraphBlock GraphCensoringTruncation

MonitorsSamples MonitorsSummary MonitorsDeviance MonitorsPlugin

UpdaterUpdaters UpdaterMethods UpdaterUnivariate UpdaterMultivariate UpdaterContinuous UpdaterEmpty UpdaterActions UpdaterMetmonitor

GraphConstant GraphMixture GraphStack GraphFlat GraphGeneric GraphClock

LindevCPM LindevCPT LindevCPB LindevCPS LindevCPP LindevCPE LindevCPH LindevCPL486 LindevCPC486 LindevCPV486

BugsVersion BugsGrammar BugsNames BugsIndex BugsVariables BugsParser BugsEvaluate BugsNodes
BugsOptimize BugsChaingraph BugsCodegen BugsCPCompiler BugsData BugsDeviance BugsInterface BugsInfo
Services

BugsScripting BugsTraphandler1 BugsPrettyprinter

BugsEmbed BugsRobjects

DiffExternal DiffResources UDevExternal UDevResources

BugsRectData BugsSplusData


SamplesMonitors SamplesIndex SamplesInterface SamplesFormatted SamplesEmbed

SummaryMonitors SummaryIndex SummaryInterface SummaryFormatted SummaryEmbed


RanksMonitors RanksIndex RanksInterface RanksFormatted RanksEmbed

DevianceMonitors DeviancePlugin DevianceIndex DevianceInterface DevianceFormatted DevianceEmbed

CorrelInterface CorrelFormatted CorrelEmbed

GraphCloglog GraphCut GraphDensity GraphEigenvals GraphGammap GraphInprod GraphInverse GraphKepler GraphLog GraphLogdet GraphLogit GraphProbit GraphProduct GraphRanks GraphSumation GraphTable GraphFunctional GraphODEmath GraphODElang
GraphPiecewise GraphODEBlockL GraphODEBlockM
GraphPValue GraphReplicate GraphItermap

GraphBern GraphBinomial GraphCat GraphFounder GraphGeometric GraphGeometric0 GraphHypergeometric GraphMendelian GraphNegbin GraphPoisson GraphRecessive

GraphMultinom

GraphBeta GraphChisqr GraphDbexp GraphExp GraphF GraphGEV GraphGPD GraphGamma GraphGengamma GraphLogistic GraphLognorm GraphNormal GraphPareto GraphPolygene GraphStable GraphT GraphTrapezium GraphUniform GraphWeibull GraphWeibullShifted

GraphDirichlet GraphMVNormal GraphMVT GraphRENormal GraphStochtrend
GraphWishart

GraphScalarT GraphVectorT GraphUnivariateT GraphScalartemp1 GraphVectortemp1
GraphUnivariatetemp1

DiffChangePoints DiffExponential DiffFiveCompModel DiffLotkaVolterra DiffTemplateModule

UDevExternal UDevResources UDevScalar UDevScalarTemplate UDevVector UDevVectorTemplate UDevDJLPKIVbol2 UDevDJLPKIVbol3 UDevElicitorPiecewise UDevEmax UDevDJL2CompDisp UDevDJL3CompDisp UDevSparseMatrixVectorProduct

UpdaterHybrid1D UpdaterAM UpdaterDE UpdaterHybrid

UpdaterForward

UpdaterBeta UpdaterCatagorical UpdaterDFreeARS UpdaterDescreteSlice
UpdaterGriddy UpdaterGamma UpdaterMetover UpdaterDFreeHybrid1D UpdaterMetbinomial UpdaterMetnormal UpdaterNormal UpdaterPareto UpdaterPoisson UpdaterRejection UpdaterSCAM UpdaterSCDE UpdaterSlice UpdaterNaivemet

UpdaterAMblock UpdaterAMNLLS UpdaterChain UpdaterDEBlock UpdaterDirichlet
UpdaterDirichletprior UpdaterDirichletpriorRW UpdaterDFreeHybrid UpdaterGLM UpdaterGMRF UpdaterHybridnormal UpdaterHybridglm UpdaterMultinomial UpdaterMVNormal UpdaterMVNLinear UpdaterWishart

UpdaterUnivariateT UpdaterMultivariateT

SpatialBound SpatialCARl1 SpatialCARNormal SpatialCARProper SpatialStrucMVN SpatialDiscKrig SpatialExpKrig SpatialMaternKrig SpatialPoissconv SpatialMVCAR
UpdaterKrigparam

BugsExternal BugsMessages BugsScripts CorrelMessages DevianceMessages
GraphMessages RanksMessages SamplesMessages SpatialExternal SummaryMessages
UpdaterMessages UpdaterExternal MapsMessages

BugsResources CorrelResources DevianceResources GraphResources RanksResources
SamplesResources SpatialResources SummaryResources UpdaterResources MapsResources

ReliabilityBS ReliabilityBurrXII ReliabilityBurrX ReliabilityExpPower ReliabilityExpoWeibull ReliabilityExtExp ReliabilityExtendedWeibull ReliabilityFlexibleWeibull ReliabilityGenExp ReliabilityGPWeibull ReliabilityGompertz ReliabilityGumbel ReliabilityInvGauss ReliabilityInvWeibull ReliabilityLinearFailure ReliabilityLogisticExp ReliabilityLogLogistic ReliabilityLogWeibull ReliabilityModifiedWeibull ReliabilityExternal ReliabilityResources

Startup BugsCLI

BugsC# [linking6]


(*   need to have Linux version of Kernel.ocf and HostFile.ocf in correct place   *)

To create a fully linked OpenBUGS library for Linux click in the round blob
[linking7]DevElfLinker.LinkDll
libOpenBUGS.so := Kernel$+ Files HostFiles Meta Console LinConsole BugsInterpreter

Math Strings Dialog Stores Services

BugsMappers BugsStrings BugsFiles BugsStdInterpreter
BugsMsg BugsRegistry

MathSort MathMatrix MathSparsematrix MathFunc MathRandnum MathODE MathFunctional MathRungeKutta45 MathAESolver MathIntegrate
MathLincon MathTT800 MathDiagmatrix MathBGR MathSmooth

GraphRules GraphNodes GraphLogical GraphStochastic GraphScalar GraphVector GraphLimits GraphUnivariate GraphMultivariate GraphConjugateMV GraphChain GraphGMRF
GraphBlock GraphCensoringTruncation

MonitorsSamples MonitorsSummary MonitorsDeviance MonitorsPlugin

UpdaterUpdaters UpdaterMethods UpdaterUnivariate UpdaterMultivariate UpdaterContinuous UpdaterEmpty UpdaterActions UpdaterMetmonitor

GraphConstant GraphMixture GraphStack GraphFlat GraphGeneric GraphClock

LindevCPM LindevCPT LindevCPB LindevCPS LindevCPP LindevCPE LindevCPH LindevCPL486 LindevCPC486 LindevCPV486

BugsVersion BugsGrammar BugsNames BugsIndex BugsVariables BugsParser BugsEvaluate BugsNodes BugsOptimize BugsChaingraph BugsCodegen BugsCPCompiler BugsData BugsDeviance BugsInterface BugsInfo

BugsScripting BugsTraphandler1 BugsPrettyprinter

BugsEmbed BugsRobjects

DiffExternal DiffResources UDevExternal UDevResources

BugsRectData BugsSplusData


SamplesMonitors SamplesIndex SamplesInterface SamplesFormatted SamplesEmbed

SummaryMonitors SummaryIndex SummaryInterface SummaryFormatted SummaryEmbed


RanksMonitors RanksIndex RanksInterface RanksFormatted RanksEmbed

DevianceMonitors DeviancePlugin DevianceIndex DevianceInterface DevianceFormatted DevianceEmbed

CorrelInterface CorrelFormatted CorrelEmbed

GraphCloglog GraphCut GraphDensity GraphEigenvals GraphGammap GraphInprod GraphInverse GraphKepler GraphLog GraphLogdet GraphLogit GraphProbit GraphProduct GraphRanks GraphSumation GraphTable GraphFunctional GraphODEmath GraphODElang
GraphPiecewise GraphODEBlockL GraphODEBlockM
GraphPValue GraphReplicate GraphItermap

GraphBern GraphBinomial GraphCat GraphFounder GraphGeometric GraphGeometric0 GraphHypergeometric GraphMendelian GraphNegbin GraphPoisson GraphRecessive

GraphMultinom

GraphBeta GraphChisqr GraphDbexp GraphExp GraphF GraphGEV GraphGPD GraphGamma GraphGengamma GraphLogistic GraphLognorm GraphNormal GraphPareto GraphPolygene GraphStable GraphT GraphTrapezium GraphUniform GraphWeibull GraphWeibullShifted

GraphDirichlet GraphMVNormal GraphMVT GraphRENormal GraphStochtrend
GraphWishart

GraphScalarT GraphVectorT GraphUnivariateT GraphScalartemp1 GraphVectortemp1
GraphUnivariatetemp1

DiffChangePoints DiffExponential DiffFiveCompModel DiffLotkaVolterra DiffTemplateModule

UDevExternal UDevResources UDevScalar UDevScalarTemplate UDevVector UDevVectorTemplate UDevDJLPKIVbol2 UDevDJLPKIVbol3 UDevElicitorPiecewise UDevEmax UDevDJL2CompDisp UDevDJL3CompDisp UDevSparseMatrixVectorProduct

UpdaterHybrid1D UpdaterAM UpdaterDE UpdaterHybrid

UpdaterForward

UpdaterBeta UpdaterCatagorical UpdaterDFreeARS UpdaterDescreteSlice
UpdaterGriddy UpdaterGamma UpdaterMetover UpdaterDFreeHybrid1D UpdaterMetbinomial UpdaterMetnormal UpdaterNormal UpdaterPareto UpdaterPoisson UpdaterRejection UpdaterSCAM UpdaterSCDE UpdaterSlice UpdaterNaivemet

UpdaterAMblock UpdaterAMNLLS UpdaterChain UpdaterDEBlock UpdaterDirichlet
UpdaterDirichletprior UpdaterDirichletpriorRW UpdaterDFreeHybrid UpdaterGLM UpdaterGMRF UpdaterHybridnormal UpdaterHybridglm UpdaterMultinomial UpdaterMVNormal UpdaterMVNLinear UpdaterWishart

UpdaterUnivariateT UpdaterMultivariateT

SpatialBound SpatialCARl1 SpatialCARNormal SpatialCARProper SpatialStrucMVN SpatialDiscKrig SpatialExpKrig SpatialMaternKrig SpatialPoissconv SpatialMVCAR
UpdaterKrigparam

BugsExternal BugsMessages BugsScripts CorrelMessages DevianceMessages GraphMessages RanksMessages SamplesMessages SpatialExternal SummaryMessages
UpdaterMessages UpdaterExternal MapsMessages

BugsResources CorrelResources DevianceResources GraphResources RanksResources
SamplesResources SpatialResources SummaryResources UpdaterResources MapsResources

ReliabilityBS ReliabilityBurrXII ReliabilityBurrX ReliabilityExpPower ReliabilityExpoWeibull ReliabilityExtExp ReliabilityExtendedWeibull ReliabilityFlexibleWeibull ReliabilityGenExp ReliabilityGPWeibull ReliabilityGompertz ReliabilityGumbel ReliabilityInvGauss ReliabilityInvWeibull ReliabilityLinearFailure ReliabilityLogisticExp ReliabilityLogLogistic ReliabilityLogWeibull ReliabilityModifiedWeibull ReliabilityExternal ReliabilityResources

Startup BugsCLI

BugsC# [linking8]



Click the blobs to make SlaveBUGS for multiprocessor updating.

[linking9]DevLinker.Link
WorkerBUGS.exe := Kernel$ + Files HostFiles HostPackedFiles StdLoader
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 [linking10]

[linking11] DevPacker.PackThis WorkerBUGS.exe :=
gpl-3.0.txt
Bugs/Rsrc/Menus.odc
Doodle/Rsrc/Menus.odc
Maps/Rsrc/Menus.odc
Rsrc/Menus.odc => System/Rsrc/Menus.odc
Rsrc/About.odc => System/Rsrc/About.odc[linking12]


Click the blobs to make MultiBUGS for multiprocessor updating.

[linking13]DevLinker.Link
MultiBUGS.exe := Kernel$ + Files HostFiles HostPackedFiles StdLoader
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 [linking14]

[linking15] DevPacker.PackThis MultiBUGS.exe :=
gpl-3.0.txt
Bugs/Rsrc/MenusMulti.odc => Bugs/Rsrc/Menus.odc
Doodle/Rsrc/Menus.odc
Maps/Rsrc/Menus.odc
Rsrc/MenusMulti.odc => System/Rsrc/Menus.odc
Rsrc/AboutMulti.odc => System/Rsrc/About.odc[linking16]