{"id":85,"date":"2013-02-10T08:00:14","date_gmt":"2013-02-10T08:00:14","guid":{"rendered":"http:\/\/www.appinf.com\/blog\/?p=85"},"modified":"2021-11-18T20:47:38","modified_gmt":"2021-11-18T19:47:38","slug":"where-to-put-the-osp-codecache-directory","status":"publish","type":"post","link":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/","title":{"rendered":"Where to Put The OSP CodeCache Directory"},"content":{"rendered":"\n<p>One of the questions that comes up frequently when installing an OSP-based application on an end-user system is where to put the OSP <em>codeCache<\/em>. The <em>codeCache<\/em> is a directory where the OSP framework puts all shared libraries contained in bundles, so that the operating system can find and load them. The OSP framework itself does not care where the <em>codeCache<\/em> is located, so you\u2019re basically free to put it wherever you\u2019d like. Of course, there are system-specific conventions and restrictions where such things like the codeCache should or can be stored. Also, the location will be different whether your application is a server application that runs in the background, or an interactive desktop application.<\/p>\n\n\n\n<p>For example, on Windows, the codeCache should go into the AppData\\Local\\ directory within the user\u2019s home directory for a desktop application. If the application runs as a Windows service, another directory might be more appropriate \u2014 in this case it might be possible to put the codeCache into the Program Files folder. On a Linux system, for an interactive application, the codeCache should go into a hidden application-specific directory within the user\u2019s home directory, whereas on Mac OS X, ~\/Library\/Application Support\/ is the right place. For a Unix server application (daemon), \/var\/cache\/ is a good choice.<\/p>\n\n\n\n<p>To make configuring the codeCache location in the application\u2019s configuration file easier, it is a good idea to define a configuration property in your application that makes the path to the directory containing the codeCache available.<\/p>\n\n\n\n<p>Following is some sample code that determines an appropriate directory for holding the codeCache on Windows, Mac OS X and other Unix platforms, for desktop applications.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>std::string findApplicationDataDir(\n\u00a0 \u00a0 const std::string&amp; vendorName,\n\u00a0 \u00a0 const std::string&amp; applicationName)\n\n{\n#if POCO_OS == POCO_OS_WINDOWS_NT\n\u00a0 \u00a0 wchar_t wpath[MAX_PATH];\n\u00a0 \u00a0 HRESULT rc = SHGetFolderPathW(\n\u00a0 \u00a0 \u00a0 \u00a0 NULL,\n\u00a0 \u00a0 \u00a0 \u00a0 CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE,\n\u00a0 \u00a0 \u00a0 \u00a0 NULL, SHGFP_TYPE_CURRENT,\n\u00a0 \u00a0 \u00a0 \u00a0 wpath);\n\u00a0 \u00a0 if (SUCCEEDED(rc))\n\u00a0 \u00a0 {\n\u00a0 \u00a0 \u00a0 \u00a0 std::string localAppData;\n\u00a0 \u00a0 \u00a0 \u00a0 Poco::UnicodeConverter::toUTF8(wpath, localAppData);\n\u00a0 \u00a0 \u00a0 \u00a0 Poco::Path path(localAppData);\n\u00a0 \u00a0 \u00a0 \u00a0 path.makeDirectory();\n\u00a0 \u00a0 \u00a0 \u00a0 path.pushDirectory(vendorName);\n\u00a0 \u00a0 \u00a0 \u00a0 path.pushDirectory(applicationName);\n\u00a0 \u00a0 \u00a0 \u00a0 return path.toString();\n\u00a0 \u00a0 }\n\u00a0 \u00a0 else return config().getString(\"application.dir\");\n\n#elif POCO_OS == POCO_OS_MAC_OS_X\n\u00a0 \u00a0 Poco::Path path(Poco::Path::home());\n\u00a0 \u00a0 path.pushDirectory(\"Library\");\n\u00a0 \u00a0 path.pushDirectory(\"Application Support\");\n\u00a0 \u00a0 path.pushDirectory(vendorName);\n\u00a0 \u00a0 path.pushDirectory(applicationName);\n\u00a0 \u00a0 return path.toString();\n\n#else\n\u00a0 \u00a0 Poco::Path path(Poco::Path::home());\n\u00a0 \u00a0 path.pushDirectory(\".\" + vendorName);\n\u00a0 \u00a0 path.pushDirectory(applicationName);\n\u00a0 \u00a0 return path.toString();\n#endif\n}<\/code><\/pre>\n\n\n\n<p>Note that the SHGetFolderPath API function has been deprecated as of Windows Vista, superseded by SHGetKnownFolderPath. However, the latter one is not available on XP, so if you still have to support XP deployments, you've got to use the deprecated SHGetFolderPath function (which now is just a wrapper for SHGetKnownFolderPath).<\/p>\n\n\n\n<p>For the above code to work on Windows, you\u2019ll need to #include &lt;shlobj.h&gt;, as well as #include \"Poco\/UnicodeConverter.h\" and link with shell32.lib.<\/p>\n\n\n\n<p>If you change the BundleServer\u2019s initialize() function to look like below, then you can refer to that directory in your application configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>void initialize(Application&amp; self)\n{\n\u00a0 \u00a0 std::string appDataDir(findApplicationDataDir(\n\u00a0 \u00a0 \u00a0 \u00a0 \"MyCompany\", \"MyApplication\"));\n\u00a0 \u00a0 config().setString(\"application.dataDir\", appDataDir);\n\u00a0 \u00a0 loadConfiguration();\n\u00a0 \u00a0 Application::initialize(self);\n}<\/code><\/pre>\n\n\n\n<p>This code determines the data directory and stores the path in the application.dataDir configuration property. In the application properties file, you can now specify:<\/p>\n\n\n\n<p><code>osp.codeCache = ${application.dataDir}codeCache<\/code><\/p>\n\n\n\n<p>Note that for a server application, in most cases no extra code is needed to determine the directory \u2014 all can be done in the configuration file. For example, on Windows, use the application's installation directory:<\/p>\n\n\n\n<p><code>osp.codeCache =  ${application.dir}codeCache<\/code><\/p>\n\n\n\n<p>On UNIX platforms, use \/var\/cache:<\/p>\n\n\n\n<p><code>osp.codeCache = \/var\/cache<\/code><\/p>\n\n\n\n<p>And as a final note, on some Unix platforms, depending on the configuration of the dynamic linker, it may be necessary to set up the shared library search path (LD_LIBRARY_PATH) so that it includes the codeCache directory. Otherwise the OSP application will not be able to load the shared libraries from the codeCache. This can be done in the application's startup script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the questions that comes up frequently when installing an OSP-based application on an end-user system is where to put the OSP codeCache. The codeCache is a directory where the OSP framework puts all shared libraries contained in bundles, so that the operating system can find and load them. The OSP framework itself does [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_eb_attr":"","footnotes":""},"categories":[24,13],"tags":[23],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]\" \/>\n<meta property=\"og:description\" content=\"One of the questions that comes up frequently when installing an OSP-based application on an end-user system is where to put the OSP codeCache. The codeCache is a directory where the OSP framework puts all shared libraries contained in bundles, so that the operating system can find and load them. The OSP framework itself does [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\" \/>\n<meta property=\"og:site_name\" content=\"macchina.io Blog [STAGING]\" \/>\n<meta property=\"article:published_time\" content=\"2013-02-10T08:00:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-18T19:47:38+00:00\" \/>\n<meta name=\"author\" content=\"G\u00fcnter Obiltschnig\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@macchina_io\" \/>\n<meta name=\"twitter:site\" content=\"@macchina_io\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"G\u00fcnter Obiltschnig\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\"},\"author\":{\"name\":\"G\u00fcnter Obiltschnig\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/person\/85e732123d4102689b6436b2807a626b\"},\"headline\":\"Where to Put The OSP CodeCache Directory\",\"datePublished\":\"2013-02-10T08:00:14+00:00\",\"dateModified\":\"2021-11-18T19:47:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\"},\"wordCount\":522,\"publisher\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#organization\"},\"keywords\":[\"osp\"],\"articleSection\":[\"OSP\",\"Tips &amp; Tricks\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\",\"url\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\",\"name\":\"Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]\",\"isPartOf\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#website\"},\"datePublished\":\"2013-02-10T08:00:14+00:00\",\"dateModified\":\"2021-11-18T19:47:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/web-staging.macchina.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Where to Put The OSP CodeCache Directory\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#website\",\"url\":\"https:\/\/web-staging.macchina.io\/blog\/\",\"name\":\"macchina.io Blog [STAGING]\",\"description\":\"Internet of Things, edge computing, IoT device software, C++\",\"publisher\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/web-staging.macchina.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#organization\",\"name\":\"macchina.io\",\"url\":\"https:\/\/web-staging.macchina.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/macchina.io\/blog\/wp-content\/uploads\/2018\/08\/macchina.io_emp_logo.png\",\"contentUrl\":\"https:\/\/macchina.io\/blog\/wp-content\/uploads\/2018\/08\/macchina.io_emp_logo.png\",\"width\":1537,\"height\":529,\"caption\":\"macchina.io\"},\"image\":{\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/macchina_io\",\"https:\/\/www.linkedin.com\/showcase\/37869369\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/person\/85e732123d4102689b6436b2807a626b\",\"name\":\"G\u00fcnter Obiltschnig\",\"sameAs\":[\"http:\/\/www.appinf.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/","og_locale":"en_US","og_type":"article","og_title":"Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]","og_description":"One of the questions that comes up frequently when installing an OSP-based application on an end-user system is where to put the OSP codeCache. The codeCache is a directory where the OSP framework puts all shared libraries contained in bundles, so that the operating system can find and load them. The OSP framework itself does [&hellip;]","og_url":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/","og_site_name":"macchina.io Blog [STAGING]","article_published_time":"2013-02-10T08:00:14+00:00","article_modified_time":"2021-11-18T19:47:38+00:00","author":"G\u00fcnter Obiltschnig","twitter_card":"summary_large_image","twitter_creator":"@macchina_io","twitter_site":"@macchina_io","twitter_misc":{"Written by":"G\u00fcnter Obiltschnig","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#article","isPartOf":{"@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/"},"author":{"name":"G\u00fcnter Obiltschnig","@id":"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/person\/85e732123d4102689b6436b2807a626b"},"headline":"Where to Put The OSP CodeCache Directory","datePublished":"2013-02-10T08:00:14+00:00","dateModified":"2021-11-18T19:47:38+00:00","mainEntityOfPage":{"@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/"},"wordCount":522,"publisher":{"@id":"https:\/\/web-staging.macchina.io\/blog\/#organization"},"keywords":["osp"],"articleSection":["OSP","Tips &amp; Tricks"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/","url":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/","name":"Where to Put The OSP CodeCache Directory - macchina.io Blog [STAGING]","isPartOf":{"@id":"https:\/\/web-staging.macchina.io\/blog\/#website"},"datePublished":"2013-02-10T08:00:14+00:00","dateModified":"2021-11-18T19:47:38+00:00","breadcrumb":{"@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/web-staging.macchina.io\/blog\/tips-tricks\/where-to-put-the-osp-codecache-directory\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web-staging.macchina.io\/blog\/"},{"@type":"ListItem","position":2,"name":"Where to Put The OSP CodeCache Directory"}]},{"@type":"WebSite","@id":"https:\/\/web-staging.macchina.io\/blog\/#website","url":"https:\/\/web-staging.macchina.io\/blog\/","name":"macchina.io Blog [STAGING]","description":"Internet of Things, edge computing, IoT device software, C++","publisher":{"@id":"https:\/\/web-staging.macchina.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web-staging.macchina.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web-staging.macchina.io\/blog\/#organization","name":"macchina.io","url":"https:\/\/web-staging.macchina.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/macchina.io\/blog\/wp-content\/uploads\/2018\/08\/macchina.io_emp_logo.png","contentUrl":"https:\/\/macchina.io\/blog\/wp-content\/uploads\/2018\/08\/macchina.io_emp_logo.png","width":1537,"height":529,"caption":"macchina.io"},"image":{"@id":"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/macchina_io","https:\/\/www.linkedin.com\/showcase\/37869369"]},{"@type":"Person","@id":"https:\/\/web-staging.macchina.io\/blog\/#\/schema\/person\/85e732123d4102689b6436b2807a626b","name":"G\u00fcnter Obiltschnig","sameAs":["http:\/\/www.appinf.com"]}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/posts\/85"}],"collection":[{"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":14,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":893,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions\/893"}],"wp:attachment":[{"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web-staging.macchina.io\/blog\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}