00200-GettingStarted.page 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. Getting Started With The POCO C++ Libraries
  2. AAAIntroduction
  3. !!!Welcome
  4. Thank you for downloading the POCO C++ Libraries and welcome to the growing community of POCO C++ Libraries
  5. users. This document will help you in getting a smooth ride while installing and setting up the
  6. POCO C++ Libraries and going the first steps with the software.
  7. !!!Setting Up The POCO C++ Libraries
  8. The POCO C++ Libraries are delivered in full source code only. Due to the
  9. large number of possible build configurations, no binary releases are provided
  10. from the project maintainers.
  11. This means that you have to build the libraries and tools before you can use them the first time.
  12. <*Note: There are binary releases available as installation packages for
  13. various operating systems (e.g., Debian Linux, Ubuntu Linux, OpenBSD,
  14. OpenWRT, etc.). However, these packages are not maintained by the core
  15. team and may not always be up to date.*>
  16. Up-to-date [[https://conan.io Conan]] packages are available via
  17. [[https://bintray.com/pocoproject/conan/Poco%3Apocoproject Bintray]].
  18. !!Source Code Distribution Format
  19. The source code for the POCO C++ Libraries is delivered in a ZIP file
  20. for Windows users and/or in a compressed TAR file (.tar.gz or .tar.bz2)
  21. for Unix/Linux users. Both archives contain the same files, the only
  22. difference is that all text files in the ZIP files have line endings
  23. suitable for Windows (CR-LF), while the text files in the TAR file have
  24. line endings suitable for Unix/Linux (LF only).
  25. All libraries and tools follow a common convention for the directory
  26. layout. This directory layout is shown below.
  27. build/ the build system for Unix and additional utility scripts
  28. config/ build configurations for various Unix platforms
  29. rules/ common build rules for all platforms
  30. scripts/ build and utility scripts
  31. vxconfig/ VxWorks build configurations
  32. cmake/ Support files for CMake
  33. bin/ all executables (dynamic link libraries on Windows)
  34. bin64/ all 64-bit executables (and DLLs)
  35. doc/ additional documentation
  36. lib/ all libraries (import libraries on Windows)
  37. lib64/ all 64-bit libraries
  38. CppUnit/ project and make/build files for the CppUnit unit testing framework
  39. doc/ additional documentation
  40. include/
  41. CppUnit/ header files for CppUnit
  42. src/ source files for CppUnit
  43. WinTestRunner/ Windows GUI for CppUnit
  44. Foundation/ project and make/build files for the Foundation library
  45. include/
  46. Poco/ header files for the Foundation library
  47. src/ source files for the Foundation library
  48. testsuite/ project and make/build files for the Foundation testsuite
  49. src/ source files for the Foundation testsuite
  50. bin/ test suite executables
  51. samples/ sample applications for the Foundation library
  52. XML/ project and make/build files for the XML library
  53. include/
  54. Poco/
  55. XML/ header files for the core XML library
  56. SAX/ header files for SAX support
  57. DOM/ header files for DOM support
  58. src/ source files for the XML library
  59. testsuite/ project and make/build files for the XML testsuite
  60. src/ source files for the XML testsuite
  61. bin/ test suite executables
  62. samples/ sample applications for the XML library
  63. Net/ project and make/build files for the Net library
  64. include/
  65. Poco/
  66. Net/ header files for the Net library
  67. src/ source files for the Net library
  68. testsuite/ project and make/build files for the Net testsuite
  69. src/ source files for the Net testsuite
  70. bin/ test suite executables
  71. samples/ sample applications for the Net library
  72. ----
  73. Depending on what package you have downloaded (Basic or Complete
  74. Edition), there may be other libraries as well (such as Data, Crypto,
  75. NetSSL_OpenSSL and Zip).
  76. !!External Dependencies
  77. The following libraries require third-party software (header files and
  78. libraries) being installed to build properly:
  79. - NetSSL_OpenSSL and Crypt require OpenSSL.
  80. - Data/ODBC requires ODBC
  81. (Microsoft ODBC on Windows, unixODBC or iODBC on Unix/Linux)
  82. - Data/MySQL requires the MySQL client.
  83. !OpenSSL
  84. <*Unix/Linux*>
  85. Most Unix/Linux systems already have OpenSSL
  86. preinstalled, or OpenSSL can be easily installed using the system’s
  87. package management facility. For example, on Ubuntu (or other
  88. Debian-based Linux distributions) you can type
  89. $ sudo apt-get install openssl libssl-dev
  90. ----
  91. to install the necessary packages.
  92. If your system does not have OpenSSL, please get it from
  93. http://www.openssl.org/ or another source. You do not have to build
  94. OpenSSL yourself -- a binary distribution is fine.
  95. On macOS, it's recommended to install OpenSSL via Homebrew.
  96. $ brew install openssl
  97. ----
  98. <*Windows*>
  99. On Windows, there are three options:
  100. - Use POCO pre-built OpenSSL binaries (simplest and recommended)
  101. - Build OpenSSL using scripts from POCO distribution package
  102. - Use a third-party pre-built OpenSSL
  103. <*POCO pre-built OpenSSL binaries*>
  104. OpenSSL binaries (version 1.1.0) built with Visual Studio 2013 are available for
  105. [[https://github.com/pocoproject/openssl/tree/master/VS_120 download]].
  106. In case you are using pre-built binaries, please make sure to copy the
  107. entire directory to <*C:\%POCO_BASE%\openssl\*>.
  108. Or, %POCO_BASE%\openssl directory can be deleted and openssl
  109. repository cloned:
  110. $ cd %POCO_BASE%
  111. $ rmdir /s /q openssl
  112. $ git clone https://github.com/pocoproject/openssl
  113. All libraries are located in their proper folders (eg. <*win64/bin/debug/*>),
  114. and all are named identically (<*libcrypto*> and <*libssl*>).
  115. <*Build OpenSSL using scripts from POCO distribution package*>
  116. Alternatively, if you choose to build your own OpenSSL, POCO C++ Libraries
  117. distribution package comes with scripts to build OpenSSL on Windows operating
  118. system. This requires Windows PowerShell.
  119. Usage:
  120. C:\%POCO_BASE%\openssl\build.ps1 [-openssl_release 1.0.0 | 1.1.0]
  121. [-vs_version 150 | 140 | 120 | 110 | 100 | 90]
  122. [-config release | debug | both]
  123. [-platform Win32 | x64]
  124. [-library shared | static]
  125. ----
  126. Example: Building OpenSSL 1.1.0, DLL release build for x64 with Visual Studio 2013:
  127. C:\%POCO_BASE%\openssl\build.ps1 -openssl_release 1.1.0 -vs_version 120 -config release -platform x64 -library shared
  128. ----
  129. The above command will download all the necessary packages (perl, nasm, etc)
  130. and buil OpenSSL in <*C:\%POCO_BASE%\openssl\VS_120*> directory; the built OpenSSL
  131. binaries can be linked from EXEs and DLLs built with Visual Studio 2008 to 2017.
  132. Pre-generated POCO Visual Studio projects are configured to use headers and
  133. libraries from <*VS_120*> directory.
  134. <*Use a third-party pre-built OpenSSL*>
  135. Yet another way to install OpenSSL on Windows is to use a binary
  136. (prebuild) release, for example the one from Shining Light
  137. Productions that comes with a Windows installer
  138. (http://www.slproweb.com/products/Win32OpenSSL.html).
  139. Depending on where you have installed the OpenSSL libraries,
  140. you might have to edit the build script (buildwin.cmd), or add the
  141. necessary paths to the INCLUDE and LIB environment variables. You might also
  142. have to edit the project settings if the names of the OpenSSL libraries
  143. from your build differ from the names used in the project files.
  144. NOTE: To disable internal automatic linking of supplied binaries in pre-generated
  145. POCO Visual Studio projects, define <[POCO_EXTERNAL_OPENSSL]> in your build environment.
  146. Alternatively, you can either rename your binaries, or edit the
  147. <*%POCO_BASE%\Crypto\include\Poco\Crypto\Crypto.h*> file if the names of the
  148. OpenSSL libraries from your build differ from the names used thereof
  149. (look for "#pragma comment" lines in <*Crypto.h*>).
  150. !ODBC
  151. The Data library requires ODBC support on your system if you want to
  152. build the ODBC connector (which is the default). On Windows platforms,
  153. ODBC should be readily available if you have the Windows SDK installed.
  154. On Unix/Linux platforms, you can use [[http://www.iodbc.org/ iODBC]]
  155. or [[http://www.unixodbc.org/ unixODBC]. On
  156. Linux, use your distribution's package management system to install the
  157. necessary libraries and header files. For example, on Ubuntu, type
  158. $ sudo apt-get install libiodbc2 libiodbc2-dev
  159. ----
  160. to install the iODBC library and header files.
  161. The Data/ODBC and Data/MySQL Makefiles will search for the ODBC and
  162. MySQL headers and libraries in various places. Nevertheless, the
  163. Makefiles may not be able to find the headers and libraries. In this
  164. case, please edit the Makefile in Data/ODBC and/or Data/MySQL
  165. accordingly.
  166. !MySQL Client
  167. The Data library requires the [[http://dev.mysql.com MySQL]] client
  168. libraries and header files if you want to build the MySQL connector
  169. (which is the default). On Windows platforms, use the MySQL client
  170. installer to install the necessary files. On Unix/Linux platforms, use
  171. the package management system of your choice to install the necessary
  172. files. Alternatively, you can of course build MySQL yourself from
  173. source.
  174. !!Building using CMake
  175. As an alternative to the platform specific Makefiles and Solutions, CMake can be used
  176. to do build Poco. CMake is a cross platform Makefile generator that also supports
  177. Microsoft Visual Studio and Apple Xcode.
  178. Poco requires CMake 3.0 or higher. Static binaries for many platforms can be downloaded from http://www.cmake.org/
  179. CMake supports out of source builds and this is the recommended way to build Poco using CMake.
  180. Assuming you are currently in the Poco source directory on a Unix machine
  181. and you like to build Poco with the generated Makefiles just type the following commands.
  182. $ mkdir cmake_build
  183. $ cd cmake_build
  184. $ cmake ..
  185. $ make
  186. This will build Poco in a subdirectory <*cmake_build*>. All files produced during build are located in this directory.
  187. CMake allows you to set some build time options. As an example: to disable the SevenZip support
  188. type the following command:
  189. $ cmake -DENABLE_SEVENZIP=OFF ..
  190. Similar options are available for other components (see: CMakeLists.txt).
  191. If you cannot or do not want to build with CMake, there are other options,
  192. described in the following.
  193. !!Building On Windows
  194. Microsoft Visual Studio 2008 or newer is required to build the
  195. POCO C++ Libraries on Windows platforms.
  196. Solution and project files for all versions are included.
  197. 64-bit (x64) builds are supported as well.
  198. You can either build from within Visual Studio (<*Build->Batch
  199. Build->Select All;Rebuild*>) or from the command line. To build from the
  200. command line, start the Visual Studio 2008 (or 2010, 2013, etc.) Command
  201. Prompt and go (<[cd]>) to the directory where you have extracted the POCO
  202. C++ Libraries sources. Then, simply start the <*buildwin.cmd*> script and
  203. pass as argument the version of visual studio (90, 100, 110, ... 150). You
  204. can customize what is being built by <*buildwin.cmd*> by passing appropriate
  205. command line arguments to it. Call <*buildwin.cmd*> without arguments to see
  206. what is available. Build environment is set up by the buildwin.cmd; to avoid
  207. build problems, it is recommended to start the build in a clean command
  208. prompt console, i.e. not in the one provided by Visual Studio for 32/64-bit
  209. builds (although those will work fine if used appropriately for the right
  210. 32/64-bit build type).
  211. To disable certain components (e.g., NetSSL_OpenSSL or Data/MySQL) from
  212. the build, edit the text file named <*components*> in the distribution
  213. root directory and remove or comment the respective lines.
  214. Certain libraries, like NetSSL_OpenSSL, Crypto or Data/MySQL have
  215. dependencies to other libraries. Since the build script does not know where to
  216. find the necessary header files and import libraries, you have to either add
  217. the header file paths to the <[INCLUDE]> environment variable and the
  218. library path to the <[LIB]> environment variable, or you'll have to edit the
  219. buildwin.cmd script, where these environment variables can be set as
  220. well.
  221. In order to run the test suite and the samples, the top-most bin
  222. directory containing the resulting shared libraries must be in the PATH
  223. environment variable.
  224. !!Building On Unix/Linux/macOS
  225. For building on Unix platforms, the POCO C++ Libraries come with their
  226. own build system. The build system is based on GNU Make 3.80 (or newer),
  227. with the help from a few shell scripts. If you do not have GNU Make 3.80
  228. (or newer) installed on your machine, you will need to download it from
  229. http://directory.fsf.org/devel/build/make.html and
  230. build and install it prior to building the POCO C++ Libraries.
  231. You can check the version of GNU Make installed on your system with
  232. $ gmake --version
  233. ----
  234. or
  235. $ make --version
  236. ----
  237. Once you have GNU Make up and running, the rest is quite simple.
  238. To extract the sources and build all libraries, testsuites and samples, simply
  239. $ gunzip poco-X.Y.tar.gz
  240. $ tar -xf poco-X.Y.tar
  241. $ cd poco-X.Y
  242. $ ./configure
  243. $ gmake -s
  244. ----
  245. For help, either invoke
  246. $ ./configure --help
  247. ----
  248. Alternatively, you can read the configure script source for a list of possible options.
  249. For starters, we recommend <[--no-tests]> and <[--no-samples]>, to reduce build times.
  250. On a multicore or multiprocessor machine, use parallel makes to speed up
  251. the build (<[make -j4]>).
  252. Once you have successfully built POCO, you can install it
  253. to <*/usr/local*> (or another directory specified as parameter
  254. to configure <[--prefix=<path>]>):
  255. $ sudo gmake -s install
  256. ----
  257. You can omit certain components from the build. For example, you might
  258. want to omit Data/ODBC or Data/MySQL if you do not have the corresponding
  259. third-party libraries (iodbc or unixodbc, mysqlclient) installed
  260. on your system. To do this, use the <[--omit]> argument to configure:
  261. $ ./configure --omit=Data/ODBC,Data/MySQL
  262. ----
  263. <*IMPORTANT: Make sure that the path to the build directory does not
  264. contain symbolic links. Furthermore, on macOS (or other systems
  265. with case insensitive filesystems), make sure that the characters in
  266. the path have the correct case. Otherwise you'll get an error saying
  267. "Current working directory not under $PROJECT_BASE.".*>
  268. !!Building On QNX Neutrino
  269. For QNX Neutrino, the Unix build system (see the instructions above) is used.
  270. You can use the build system to cross-compile for a target platform on a
  271. Solaris or Linux host. Unfortunately, the Cygwin-based Windows host
  272. environment has some major quirks that prevent the build system from
  273. working there. You can also use the build system on a self-hosted QNX
  274. system. The default build configuration for QNX (found in
  275. build/config/QNX) is for a self-hosted x86 platform. To specify another
  276. target, edit the CCVER setting in the build configuration file. For
  277. example, to compile for a PowerPC target, specify
  278. CCVER=3.3.1,gcc_ntoppcbe.
  279. Service Pack 1 for QNX Neutrino 6.3 must be installed, otherwise compiling the
  280. Foundation library will fail due to a problem with the <*<list>*> header in the
  281. default (Dinkumware) C++ standard library.
  282. When building on QNX, you might want to disable NetSSL_OpenSSL, Crypto and
  283. some Data connectors, unless you have the necessary third party components
  284. available:
  285. $ ./configure --omit=NetSSL_OpenSSL,Crypto,Data/ODBC,Data/MySQL
  286. ----
  287. !!!Tutorials And Sample Code
  288. Introductory documentation consisting of various documents and tutorials
  289. in the form of slide decks can be found at the
  290. [[http://pocoproject.org/documentation/ POCO C++ Libraries Documentation]] page.
  291. Sample applications demonstrating the various features of the POCO C++
  292. Libraries are delivered with the source code. Every library's source
  293. code directory
  294. has a <*samples*> directory containing various sample applications.
  295. When building the sample applications on platforms using the gmake-based
  296. build system, please make sure that the environment variable
  297. <[POCO_BASE]> contains
  298. the path to the POCO C++ Libraries source tree root directory.
  299. !!!Creating Your Own POCO-based Applications
  300. The best way to create your first POCO-based application is by copying
  301. one of the sample projects and making the desired changes. Examine the
  302. project files and Makefiles to see what compiler options must be set for
  303. your specific platform.