{"id":2155,"date":"2016-10-15T00:01:51","date_gmt":"2016-10-15T07:01:51","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=2155"},"modified":"2016-10-08T11:59:06","modified_gmt":"2016-10-08T18:59:06","slug":"hunting-for-a-library","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=2155","title":{"rendered":"Hunting for a Library"},"content":{"rendered":"<p>To add more functionality to the C language, you mix in another library. The library contains routines (functions) that let you control specific hardware, manipulate data, work with graphics, and a host of other capabilities beyond the standard C library.<br \/>\n<!--more--><br \/>\nThe first step to adding a library is to figure out what you need the program to do. For example, if you want to program the terminal (text) window on a Mac or Linux computer, you could obtain the NCurses library.  NCurses is very interesting and fun to code, and I may explore it in the future on this blog. For now, consider that you want a library to read XML data.<\/p>\n<p>XML is the eXtensible Markup Language, essentially a text file but one with consistent elements and help organize information. A web page, or HTML document, is a type of XML file.<\/p>\n<p>Sure, you could code your own routines that parse and process XML formatted data. If you were after a quick-and-dirty tidbit of information, that trick works (and I&#8217;ve done it before). But for more control, it&#8217;s best to use an XML library. Otherwise you&#8217;re just reinventing the wheel (which happens frequently in programming).<\/p>\n<p>The two items you need to obtain are the XML library itself and its companion header file(s). Further, you need the version of the library that&#8217;s compatible with the computer&#8217;s operating system and possibly the compiler as well.<\/p>\n<p>For an XML library, I visited <a href=\"http:\/\/xmlsoft.org\/\" target=\"_blank\">The XML C parser and toolkit of Gnome<\/a> website. The Downloads link on the home page lists options to obtain the &#8220;binaries&#8221; or libraries you need for various operating systems platforms.<\/p>\n<p>As is the case with many developer tools, the binaries are probably archived and do not include an installer. This decision was made deliberately as it allows you more control; you can move or copy the files to a preferred location.<\/p>\n<p>After downloading the Windows 10 64-bit binaries, I copied the libraries into MinGW&#8217;s <code>lib<\/code> folder for use in Code::Blocks. The header files I copied into the <code>include<\/code> folder.<\/p>\n<p>The Mac comes with an XML library preinstalled. Still, if you&#8217;re after C libraries on the Mac, I recommend using the <a href=\"http:\/\/brew.sh\/\" target=\"_blank\">Homebrew<\/a> system to obtain them.<\/p>\n<p>In Linux you can download the XML library from the <a href=\"http:\/\/xmlsoft.org\" target=\"_blank\">xlmsoft.org<\/a> website, or you can use the distro&#8217;s package management tool to obtain and install new libraries.<\/p>\n<p>Once you&#8217;ve obtained and installed the libraries and headers, you can begin using the library&#8217;s functions in your programs. Don&#8217;t expect this step be easy or fast! Each library takes getting used to. The website may offer sample code plus a documentation for the API (Application Programming Interface). Give yourself time to learn it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Locate a library on the web, download and install it, then examing the API to understand how it works. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=2155\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2155","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2155"}],"version-history":[{"count":7,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2155\/revisions"}],"predecessor-version":[{"id":2180,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2155\/revisions\/2180"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}