⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compiling.html

📁 PTypes (C++ Portable Types Library) is a simple alternative to the STL that includes multithreading
💻 HTML
字号:
<html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><head><!-- #BeginEditable "doctitle" --> <title>PTypes: Compiling and Porting</title><!-- #EndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" href="styles.css"></head><body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40"><p><a href="../index.html"><img src="title-1.7.gif" width="213" height="34" alt="C++ Portable Types Library (PTypes) Version 1.7" border="0"></a> <hr noshade><!-- #BeginEditable "body" --> <p class="hpath"><a href="index.html">Top</a>: <a href="intro.html">Introduction</a>: Compiling and Porting</p><p><br><b>Supported platforms and compilers</b></p><blockquote> <p><b>Windows</b>: MSVC, BCC</p><p><b>FreeBSD</b>: GCC</p><p><b>Linux/i386, Alpha, PPC, Sparc</b>: GCC</p><p><b>SunOS/Sparc</b>: GCC</p><p><b>MacOS X/PPC (Darwin)</b>: CC - Apple Objective-C compiler</p></blockquote><p><b><br>Building on Unix</b></p><blockquote> <p>In order to build the library on one of the Unix systems listed above, run <span class="lang">make</span> in the library's root directory. The makefile in this directory actually calls makefiles in <span class="lang">src/</span> and <span class="lang">wshare/</span> with a suffix which is an output of <span class="lang">uname</span> on the given system (e.g. <span class="lang">src/Makefile.Linux</span> or <span class="lang">src/Makefile.FreeBSD</span>). Make will build the library and the demo program, and will then copy the static version of the library as <span class="lang">lib/libptypes.a</span>, the shared object version as <span class="lang">so/libptypes.so</span> (<span class="lang">so/libptypes.dylib</span> on MacOS) and the demo program as <span class="lang">bin/wshare</span>. </p><p>The public headers are in <span class="lang">include/</span>.</p><p>When building your own multithreaded application on <b>Linux</b> or <b>FreeBSD</b>, GCC requires you to specify a special command-line option <span class="lang">-pthread</span> which will automatically link POSIX threads library and the multithreaded version of libc. On <b>Linux</b> you should specify a macro <span class="lang">-D_GNU_SOURCE</span> in the command line to include the <span class="lang">rwlock</span> interface.</p><p>When building your multithreaded application on <b>SunOS</b>, you should specify a macro <span class="lang">-D_REENTRANT</span> and also link the following libraries: <span class="lang">-lpthread -lposix4</span> for multithreaded applications, and in addition, <span class="lang">-lsocket -lnsl</span> for network applications. <i>NOTE</i>: if you omit <span class="lang">-lpthread</span>, the program links without errors, but then the thread objects fail to initialize.</p><p>There is a <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=595502&group_id=56008&atid=493273">known problem</a> on Linux with GCC 2.96: multithreaded applications may crash when running many threads and intensively using dynamic memory allocation. It is recommended to compile such projects with GCC 2.95.</p></blockquote><p><b><br>Building on Windows (MSVC or BCC)</b></p><blockquote> <p><b>MSVC</b>: The MSVC project files are named <span class="lang">win32\PTypes_Lib.dsp</span> and <span class="lang">win32\PTypes_DLL.dsp</span> for the static and the dynamic versions of the library respectively. You can include one of these project files in your workspace. Make your project dependent of PTypes - this will automatically link the library to your program. To use PTypes headers you will have to explicitly specify the directory in your project settings, e.g. &quot;<span class="lang">..\ptypes\include</span>&quot;.</p><p>In order to link a program to the DLL version of PTypes use <span class="lang">PTYPES_DLL</span> macro definition when compiling your modules. You may want to add a post-build command in the MSVC environment that copies the PTypes DLL to the directory where you build and debug your own application, since otherwise your program won't be able to find the DLL module.</p><p>You should link your application with the multithreaded version of CRTL. When compiling with the dynamic version of PTypes, it is recommended also to use the DLL version of CRTL.</p><p>Specify an additional library <span class="lang">ws2_32.lib</span> if you are using PTypes' IP socket classes.</p><p><b>BCC</b>: The makefile for Borland's C/C++ compiler (aka C++Builder) is <span class="lang">src\ptypes.mak</span>. You will need tasm32.exe since some modules contain assembly code which BCC compiles using an external assembler. The BCC makefile for wshare is <span class="lang">wshare\wshare.mak</span>.</p></blockquote><p><b><br>PTypes namespace</b></p><blockquote> <p>The entire PTypes interface is enclosed within a namespace called <span class="lang">pt</span>. The header file <span class="lang">&lt;pport.h&gt;</span> provides a macro <span class="lang">USING_PTYPES</span>, which is equivalent to <span class="lang">using namespace pt</span>. This macro allows you to use PTypes interface symbols without the scope specifier <span class="lang">pt::</span> in your source code. See, for example, <span class="lang">src/ptypes_test.cxx</span>.</p></blockquote><p><b><br>Porting the library to other platforms</b></p><blockquote> <p>The author would greatly appreciate any effort to port the library to other popular platforms. If you either ported the library or just found that PTypes builds with no problem under your favorite platform with your favorite compiler, then all you'd have to do is to create a makefile with proper definitions in it. Take a look at <span class="lang">Makefile.FreeBSD</span> or <span class="lang">Makefile.SunOS</span>, for example. Besides <span class="lang">CXXOPTS</span> you can specify additional libraries through <span class="lang">LDLIBS</span>. Name your makefile so that running <span class="lang">make Makefile.`uname`</span> would work on the given operating system. Try to build the library and then run <span class="lang">src/ptypes_test</span> to make sure the library is functioning properly. </p><p>And finally, if you send the changes to the author, then (obviously) others would be able to benefit from using PTypes on your favorite operating system with your favorite compiler.</p></blockquote><p class="seealso">See also: <a href="deploying.html">Deploying the shared (dynamic) library</a></p><!-- #EndEditable --> <hr size="1"><a href="../index.html" class="ns">PTypes home</a></body><!-- #EndTemplate --></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -