{"id":2429,"date":"2019-02-01T09:53:57","date_gmt":"2019-02-01T09:53:57","guid":{"rendered":"http:\/\/www.bardecode.com\/en1\/?p=2429"},"modified":"2019-02-01T09:53:57","modified_gmt":"2019-02-01T09:53:57","slug":"calling-linux-c-library-c-code","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/calling-linux-c-library-c-code\/","title":{"rendered":"Calling the Linux C Library from C++ code"},"content":{"rendered":"<p>Here&#8217;s a quick example of how to create and build a simple C++ program that calls the basic Bardecode C library functions&#8230;<\/p>\n<p>It&#8217;s assumed that you have already downloaded the Linux version of our SDK and are working in the installation folder.<\/p>\n<p>The code:<\/p>\n<p>#include <iostream><\/p>\n<p>using namespace std;<\/p>\n<p>extern &#8220;C&#8221; {<br \/>\n#include &#8220;include\/barcode.h&#8221;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n        void *hBarcode = STCreateBarCodeSession();<\/p>\n<p>        char **bartype ;<br \/>\n        char **barvalue ;<br \/>\n        int n = STReadBarCode(hBarcode, (char *) &#8220;images\/code39_01.tif&#8221;, (char *) &#8220;tif&#8221;, &#038;barvalue, &#038;bartype);<\/p>\n<p>        cout << \"Return value = \" ;\n        cout << n ;\n        cout << \"\\n\";\n\n        if (n > 0)<br \/>\n        {<br \/>\n                cout << \"First barcode value is \";\n                cout << barvalue[0];\n                cout << \"\\n\";\n        }\n        return 0 ;\n}\n\n\nThe build (you will have to get the path right for the various libraries - we built this on Ubuntu x64):\n\ng++ -o yourcode yourcode.cpp lib\/bardecode.a \/usr\/lib\/x86_64-linux-gnu\/libtiff.so.5 \/usr\/lib\/x86_64-linux-gnu\/libjpeg.so.8 \/usr\/lib\/x86_64-linux-gnu\/libpthread.so\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a quick example of how to create and build a simple C++ program that calls the basic Bardecode C library functions&#8230; It&#8217;s assumed that you have already downloaded the Linux version of our SDK and are working in the installation folder. The code: #include using namespace std; extern &#8220;C&#8221; { #include &#8220;include\/barcode.h&#8221; } int<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/calling-linux-c-library-c-code\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":341,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,31],"tags":[],"class_list":["post-2429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge-base","category-software-development-kits"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2429"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=2429"}],"version-history":[{"count":1,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2429\/revisions"}],"predecessor-version":[{"id":2430,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2429\/revisions\/2430"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/341"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=2429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=2429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=2429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}