{"id":915,"date":"2015-03-02T15:58:13","date_gmt":"2015-03-02T14:58:13","guid":{"rendered":"http:\/\/pocoproject.org\/blog\/?p=915"},"modified":"2015-04-11T12:29:47","modified_gmt":"2015-04-11T10:29:47","slug":"poco-c-libraries-in-biicode","status":"publish","type":"post","link":"https:\/\/pocoproject.org\/blog\/?p=915","title":{"rendered":"POCO C++ Libraries in biicode"},"content":{"rendered":"<p><a href=\"http:\/\/www.biicode.com\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pocoproject.org\/blog\/wp-content\/uploads\/2015\/03\/biicode-logo.29235e86.png\" alt=\"biicode-logo.29235e86\" width=\"178\" height=\"58\" class=\"alignnone size-full wp-image-927\" \/><\/a><\/p>\n<p>The POCO C++ Libraries are now available via <a href=\"http:\/\/www.biicode.com\">biicode<\/a>, in the following versions:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.biicode.com\/fenix\/fenix\/poco\/develop\">fenix\/poco<\/a> (develop) -&gt; changing continuously<\/li>\n<li><a href=\"http:\/\/www.biicode.com\/fenix\/fenix\/poco\/v1.6.0\">fenix\/poco<\/a> (v1.6.0)<\/li>\n<li><a href=\"https:\/\/www.biicode.com\/fenix\/fenix\/poco\/v1.5.4\">fenix\/poco<\/a> (v1.5.4)<\/li>\n<li><a href=\"https:\/\/www.biicode.com\/fenix\/fenix\/poco\/v1.4.7p1\">fenix\/poco<\/a> (v1.4.7p1)<\/li>\n<\/ul>\n<p>The following post has been contributed by Fran Ram\u00edrez from the biicode team. You can also find the <a href=\"http:\/\/blog.biicode.com\/poco-cpp-libraries-available-biicode\/#more-2091\">original post<\/a> on the <a href=\"http:\/\/blog.biicode.com\">biicode blog<\/a>.<\/p>\n<h2>Benefits<\/h2>\n<p>biicode is a file based dependency manager, which has many advantages:<\/p>\n<ul>\n<li>Save time reusing from any POCO library (Foundation, Net, NetSSL_OpenSSL, etc.) such times as you need and avoid to configure and build out the libraries first. biicode&#8217;ll only retrieve the necessary files to build your project.<\/li>\n<li>POCO depends on external libraries like zlib, PCRE (Perl Compatible Regular Expressions), HPDF, 7-Zip, OpenSSL and SQLite that they&#8217;re uploaded on biicode and maintained by our users.<\/li>\n<li>It&#8217;s been tested on biicode in Windows with Visual Studio 10 and Visual Studio 12, Linux with GCC and Apple with CLang.<\/li>\n<\/ul>\n<p>I recommend you to use Visual Studio to configure your project because with MinGW you could get some errors.<\/p>\n<h2>POCO External Dependencies<\/h2>\n<p>These libraries have many external and third party dependencies to build some of them, e.g., Foundation depends on PCRE and ZLib. Without biicode PCRE and ZLib source files must be present in POCO project, but with biicode it&#8217;s not needed. The following table shows all the dependencies for every version uploaded which biicode&#8217;ll find if you use all the modules in a project:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.biicode.com\/wp-content\/uploads\/sites\/2\/2015\/02\/poco_external_deps_in_biicode-1024x136.png\" width=\"600\" height=\"80\"><\/p>\n<p>So, you\u2019ll not have to worry about to install or build them, biicode does all the effort for you \ud83d\ude09 . These are the depending blocks in biicode:<\/p>\n<ul>\n<li>PCRE(v8.36): fenix\/pcre<\/li>\n<li>PCRE(v7.8): fenix\/pcre(v7.8)<\/li>\n<li>HPDF: fenix\/hpdf<\/li>\n<li>zlib: zlib\/zlib<\/li>\n<li>7-Zip: fenix\/7z<\/li>\n<li>OpenSSL: lasote\/openSSL(v1.0.2)<\/li>\n<li>SQLite: fenix\/sqlite<\/li>\n<\/ul>\n<h2>Using POCO C++ Libraries In Your Project<\/h2>\n<p>1. Create a new project and an empty block:<\/p>\n<p><code><\/p>\n<pre>$ bii init poco_sample\r\n$ cd poco_sample\r\n$ bii new myuser\/myblock\r\n<\/pre>\n<p><\/code><\/p>\n<p>2. Add your sample code (orignal code from <em>Net\/samples\/dict.cpp<\/em>) into <em>.\/blocks\/myuser\/myblock\/sample.cpp<\/em>:<\/p>\n<p><code><\/p>\n<pre>\/\/ dict.cpp\r\n\/\/\r\n\/\/ $Id: \/\/poco\/1.4\/Net\/samples\/dict\/src\/dict.cpp#1 $\r\n\/\/\r\n\/\/ This sample demonstrates the StreamSocket and SocketStream classes.\r\n\/\/\r\n\/\/ Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.\r\n\/\/ and Contributors.\r\n\/\/\r\n\/\/ SPDX-License-Identifier:\tBSL-1.0\r\n \r\n#include \"fenix\/poco\/Net\/include\/Poco\/Net\/StreamSocket.h\"\r\n#include \"fenix\/poco\/Net\/include\/Poco\/Net\/SocketStream.h\"\r\n#include \"fenix\/poco\/Net\/include\/Poco\/Net\/SocketAddress.h\"\r\n#include \"fenix\/poco\/Foundation\/include\/Poco\/StreamCopier.h\"\r\n#include \"fenix\/poco\/Foundation\/include\/Poco\/Path.h\"\r\n#include \"fenix\/poco\/Foundation\/include\/Poco\/Exception.h\"\r\n#include <iostream>\r\n \r\nusing Poco::Net::StreamSocket;\r\nusing Poco::Net::SocketStream;\r\nusing Poco::Net::SocketAddress;\r\nusing Poco::StreamCopier;\r\nusing Poco::Path;\r\nusing Poco::Exception;\r\n \r\nint main(int argc, char** argv)\r\n{\r\n      const std::string HOST(\"dict.org\");\r\n      const unsigned short PORT = 2628;\r\n \r\n      if (argc != 2)\r\n      {\r\n            Path p(argv[0]);\r\n            std::cout << \"usage: \" << p.getBaseName() << \" <term>\" << std::endl;\r\n            std::cout << \"       looks up <term> in dict.org and prints the results\" << std::endl;\r\n            return 1;\r\n      }\r\n      std::string term(argv[1]);\r\n \r\n      try\r\n      {\r\n            SocketAddress sa(HOST, PORT);\r\n            StreamSocket sock(sa);\r\n            SocketStream str(sock);\r\n \r\n            str << \"DEFINE ! \" << term << \"\\r\\n\" << std::flush;\r\n            str << \"QUIT\\r\\n\" << std::flush;\r\n \r\n            sock.shutdownSend();\r\n            StreamCopier::copyStream(str, std::cout);\r\n      }\r\n      catch (Exception&#038; exc)\r\n      {\r\n            std::cerr << exc.displayText() << std::endl;\r\n            return 1;\r\n      }\r\n      return 0;\r\n}\r\n<\/pre>\n<p><\/code><\/p>\n<p>3.  Choose which uploaded  POCO version you want to depend on, configure it through your <em>.\/blocks\/myuser\/myblock\/biicode.conf<\/em> file. Create it and copy the following:<\/p>\n<p><code><\/p>\n<pre>[requirements]\r\n   fenix\/poco(v1.6.0): 0\r\n<\/pre>\n<p><\/code><\/p>\n<p>4. Finally, you\u2019d only have to retrieve your POCO dependencies and build your sample.cpp. For it, use this command:<\/p>\n<p><code>bii cpp:build<br \/>\n<\/code><\/p>\n<p>Note: for Windows users, to configure your project with Visual Studio, e.g., 10 version, execute:<\/p>\n<p><code>$ bii cpp:configure -G \"Visual Studio 10\"<br \/>\n$ bii cpp:build<br \/>\n<\/code><\/p>\n<p>So, biicode\u2019ll download all the dependencies from release version 1.6.0 and compile the project. Now, you can run the binary created in your .\/bin\/ folder.<\/p>\n<h2>Use The Original #include's<\/h2>\n<p>Change all the includes from the previous sample.cpp code to:<\/p>\n<p><code>...<br \/>\n#include \"Poco\/Net\/StreamSocket.h\"<br \/>\n#include \"Poco\/Net\/SocketStream.h\"<br \/>\n#include \"Poco\/Net\/SocketAddress.h\"<br \/>\n#include \"Poco\/StreamCopier.h\"<br \/>\n#include \"Poco\/Path.h\"<br \/>\n#include \"Poco\/Exception.h\"<br \/>\n...<br \/>\n<\/code><\/p>\n<p>Now, tell biicode how to find this dependencies, so, modify again the biicode.conf and add the following:<\/p>\n<p><code><\/p>\n<pre>[includes]\r\n    Poco\/Net\/*.h: fenix\/poco\/Net\/include\r\n    Poco\/*.h: fenix\/poco\/Foundation\/include\r\n<\/pre>\n<p><\/code><\/p>\n<p><b>Warning:<\/b> take care with <em>Poco\/*.h: fenix\/poco\/Foundation\/include<\/em> because it should always be at the end of [includes] section for being a really wide search pattern.<\/p>\n<p>Finally, clean the metadata and build again the project:<\/p>\n<p><code>$ bii clean<br \/>\n$ bii cpp:build<br \/>\n<\/code><\/p>\n<h2>Creating A Project With NetSSL_OpenSSL or NetSSL_Win<\/h2>\n<p>Making a project using these libraries is a special use case of original includes. Why? Take a look at the following example:<\/p>\n<p><code><\/p>\n<pre>#include \"Poco\/URIStreamOpener.h\"\r\n#include \"Poco\/StreamCopier.h\"\r\n#include \"Poco\/Path.h\"\r\n#include \"Poco\/URI.h\"\r\n#include \"Poco\/SharedPtr.h\"\r\n#include \"Poco\/Exception.h\"\r\n \r\n\/* headers in Net library *\/\r\n#include \"Poco\/Net\/HTTPStreamFactory.h\" \r\n#include \"Poco\/Net\/FTPStreamFactory.h\"\r\n \r\n\/* headers in NetSSL_OpenSSL and NetSSL_Win libraries *\/\r\n#include \"Poco\/Net\/HTTPSStreamFactory.h\" \r\n#include \"Poco\/Net\/SSLManager.h\" \r\n#include \"Poco\/Net\/KeyConsoleHandler.h\" \r\n#include \"Poco\/Net\/ConsoleCertificateHandler.h\"\r\n \r\n#include <memory>\r\n#include <iostream>\r\n \r\n\/* Main code *\/\r\n<\/pre>\n<p><\/code><\/p>\n<p>Like you see, NetSSL_OpenSSL and NetSSL_Win have the same relative inlcude headers, so, the only way to resolve successfully your dependencies is writing the full path for them.<\/p>\n<p><code><\/p>\n<pre>#include \"Poco\/URIStreamOpener.h\"\r\n#include \"Poco\/StreamCopier.h\"\r\n#include \"Poco\/Path.h\"\r\n#include \"Poco\/URI.h\"\r\n#include \"Poco\/SharedPtr.h\"\r\n#include \"Poco\/Exception.h\"\r\n \r\n\/* headers in Net library *\/\r\n#include \"Poco\/Net\/HTTPStreamFactory.h\" \r\n#include \"Poco\/Net\/FTPStreamFactory.h\"\r\n \r\n\/* headers in NetSSL_OpenSSL library *\/\r\n#include \"fenix\/poco\/NetSSL_OpenSSL\/include\/Poco\/Net\/HTTPSStreamFactory.h\" \r\n#include \"fenix\/poco\/NetSSL_OpenSSL\/include\/Poco\/Net\/SSLManager.h\" \r\n#include \"fenix\/poco\/NetSSL_OpenSSL\/include\/Poco\/Net\/KeyConsoleHandler.h\" \r\n#include \"fenix\/poco\/NetSSL_OpenSSL\/include\/Poco\/Net\/ConsoleCertificateHandler.h\"\r\n \r\n#include <memory>\r\n#include <iostream>\r\n \r\n\/* Main code *\/\r\n<\/pre>\n<p><\/code><\/p>\n<p>The biicode.conf would be like the previous one.<\/p>\n<h2>Build All POCO Samples<\/h2>\n<p>Try to build all the available samples Poco brings us with each release. Create a project, open any examples\/poco block and build it, e.g., examples from 1.4.7p1 version:<\/p>\n<p><code>$ bii init samples_1_4_7p1<br \/>\n$ bii open \"examples\/poco(v1.4.7p1)\"<br \/>\n$ bii cpp:build<br \/>\n<\/code><\/p>\n<p>So, that\u2019s all! POCO C++ Libraries are amazing and I strongly recommend you to start using them for your network projects.<\/p>\n<p>I hope you enjoy with this post and don\u2019t forget check our complete <a href=\"http:\/\/docs.biicode.com\/c++.html\">C++ documentation<\/a>! If you\u2019ve any doubt, contact us through our <a href=\"http:\/\/forum.biicode.com\">forum<\/a> or ask directly in <a href=\"http:\/\/stackoverflow.com\/questions\/tagged\/biicode\">Stackoverflow<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The POCO C++ Libraries are now available via biicode, in the following versions: fenix\/poco (develop) -&gt; changing continuously fenix\/poco (v1.6.0) fenix\/poco (v1.5.4) fenix\/poco (v1.4.7p1) The following post has been contributed by Fran Ram\u00edrez from the biicode team. You can also find the original post on the biicode blog. Benefits biicode is a file based dependency [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[],"class_list":["post-915","post","type-post","status-publish","format-standard","hentry","category-development","category-news"],"_links":{"self":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=915"}],"version-history":[{"count":17,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/915\/revisions"}],"predecessor-version":[{"id":934,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/915\/revisions\/934"}],"wp:attachment":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}