📄 dynobj-build.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org"> <title>Dynamic C++ Objects - Building</title> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <meta content="MSHTML 6.00.2900.2963" name="GENERATOR"> <link rel="stylesheet" type="text/css" href="sqs.css"></head><body> <table summary="" style="width: 600px; height: text-align: left;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td class="contents"> <br> <h2> DynObj - C++ Cross platform plugin objects </h2> <h3>Building and using the library</h3> Directory layout of the library: <ul> <LI><strong>doc</strong></LI> <ul> <LI><strong>doxygen</strong> - docs generated from doxygen</LI> </ul> <LI><strong>src</strong></LI> <ul> <LI><strong>DynObj</strong> - main source of DynObj library</LI> <ul> <LI><strong>samples</strong> - samples of using library here</LI> <LI><strong>tools</strong> - source for the <em>pdoh</em> tool</LI> <LI><strong>msdev</strong> - Visual C++ project for DynObj and samples here</LI> </ul> <LI><strong>pi</strong> - sources for platform independence layer</LI> <LI><strong>utils</strong> - utility like C++ classes</LI> </ul> </ul> A description of the <em>pdoh</em> tool is available <A href="#PDOH">here</A>.<br><br> <h3>Build model</h3> Plugin are usually opened while the application is running, so there is no build-time link between the main application and the plugins. When a plugin module is loaded, by default, the linker is instructed not to backlink into the application (Unix). On Windows, backlinking is not possible.<br><br> An application can expose functionality to plugins through interfaces. <em>DoRunTimeI</em> provides a way to make named instances of objects known globally. <br><br> <h3>Compiler defines</h3> A number of compiler defines controls how libraries and main applications are built. The defines are described in detail in <em>src/DynObj/DoSetup.h</em> (and under <em><A href="doxygen/group__DynDefs.html">DynObj defines</A></em> in doxygen doc).<br><br> When compiling a library <em>DO_MODULE</em> should be defined. Also, the name of the library should be stored in <em>DO_LIB_NAME</em> (i.e. #define DO_LIB_NAME "DynStr").<br><br> The main application should define <em>DO_MAIN</em>.<br><br> The default settings in <em>DoSetup.h</em> are OK when compiling the samples. In general the defines are used like this (example DO_USE_DYNSHARED): <ul> <LI><em>#define DO_USE_DYNSHARED</em> - The option is not used</LI> <LI><em>#define DO_USE_DYNSHARED 0</em> - The option is not used</LI> <LI><em>#define DO_USE_DYNSHARED 1</em> - The option is activated</LI> </ul> This allows having sensible defaults and for overriding them reliably from outside in a build environment.<br><br> <h3>Building the DynObj library</h3> There are two build methods provided with the library: <ul> <LI><em>Cross-platform GNU makefile</em> - This works for the g++ compiler on Unices and Windows (mingw).</LI> <LI><em>Visual C++</em> - Solution and project files for for Visual C++ on Windows.</LI> </ul> <h4>Building a plugin (module)</h4> The compiler define DO_MODULE should be set. <br> A plugin module requires compiling with: <ul> <LI>DynObj.cpp</LI> <LI>vt_test.cpp</LI> </ul> <h4>Building a main application (using plugins/modules)</h4> The compiler define DO_MAIN should be set. <br> The main application links against one of two static libraries: <ul> <LI><em>dolibdort</em> - Enables using DynObj:s and DoRunTime</LI> <LI><em>doliblt</em> - A minimalistic library without support for DoRunTime</LI> </ul> The libraries are projects in the Visual C++ solution file.<br> To build the libraries using the makefile: <p class="code"> $ cd src/DynObj<br> $ make dolibdort<br> $ make doliblt<br> </p><br> <h3>The DynStr library </h3> A run-time plugin class for strings is provided: <em>DynStr</em>. This enables plugins to use a C++ string class in a safe way, internally and in function calls. <br><br> The DynStr library is built with: <p class="code"> $ cd src/DynObj<br> $ make ds<br> </p><br> <h3>Building the samples </h3> The samples defines a <em>PersonI</em> and <em>ProfessionI</em> interfaces. Then three slightly different implementations are provided in three plugins: <em>pimpl1, pimpl2, pimpl3</em> <br><br> Three different main applications are provided as well: <em>main1, main2, main3</em>.<br><br> There are sub-projects for each of them in the VC++ solution file.<br><br> From the command prompt: <p class="code"> $ cd samples<br> $ make pimpl1<br> $ make pimpl2<br> $ make pimpl3<br> $ make bmain1<br> $ make bmain2<br> $ make bmain3<br> </p><br> <h3><A name="PDOH">The pdoh tool</A></h3> This tool takes a C++ header or source file and outputs a modified version of the file, provided it finds <em>// %%DYNOBJ</em> tags in it. It basically scans for class and struct declarations and collects inheritance information.<br><br> The pdoh tool can generate these sections: <ul> <LI>A <em>general</em> section (in a header file). This part is used by both the plugin and the main application. It contains class declarations, type IDs and the bridge from C++ types to type IDs.</LI> <LI>An <em>implement</em> section (by default in a header file). This part is used only by the plugin. To keep things simple, the code is generated inside the header file (that keeps things in one place) and the plugin must trigger inclusion of this section with a <em>#define DO_IMPLEMENT_NAMEOFLIB</em>. </LI> <LI>A <em>library</em> section. This goes into a source file and makes up the part that the user of the plugin communicates with directly. The most important function is the one that receives a type ID/ type string and instantiates this object to the caller.</LI> </ul><br> By default pdoh sends its output to stdout. Use option <em>-o</em> to overwrite the input file, or <em>-oNewFile.h</em> to write to another file. To generate less comments in the output <em>-b</em> can be used. <br><br> <em>pdoh</em> can be integrated into a build environment, it is a simple file scanner so it is fast. If it does not find any <em>//%%DYNOBJ</em> tags it will not generate any output.<br><br> If the tags have not been modified since the previous run (on the same file), it will also not generate any output (so it does not affect file time stamps when there is no need for it).<br><br> </td> </tr> </tbody> </table><br></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -