{"id":4030,"date":"2014-03-30T07:19:18","date_gmt":"2014-03-30T07:19:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-define-a-library-runtime-location-in-xcode4-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:19:18","modified_gmt":"2014-03-30T07:19:18","slug":"how-to-define-a-library-runtime-location-in-xcode4-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-define-a-library-runtime-location-in-xcode4-collection-of-common-programming-errors\/","title":{"rendered":"How to define a library runtime location in Xcode4?-Collection of common programming errors"},"content":{"rendered":"<p>In my Cocoa application I&#8217;m using a third party C-library that is compiled in command line and available in a custom location.<\/p>\n<p>In my Xcode project I can define where the library&#8217;s header files are located and where the library is looked during linking:<\/p>\n<p>Header files location (<code>HEADER_SEARCH_PATHS<\/code>):<\/p>\n<pre><code>Target &gt; Build Settings &gt; Search Paths &gt; Header Search Paths\n<\/code><\/pre>\n<p>Library location during linking (<code>LIBRARY_SEARCH_PATHS<\/code>):<\/p>\n<pre><code>Target &gt; Build Settings &gt; Search Paths &gt; Library Search Paths\n<\/code><\/pre>\n<p>But how do I define the library&#8217;s runtime location ? At the moment when I run my Cocoa application in Xcode (<code>cmd-r<\/code>) I get an error from dynamic linker:<\/p>\n<pre><code>dyld: Library not loaded: \/usr\/local\/lib\/libfoo.1.dylib\n  Reason: image not found\n<\/code><\/pre>\n<p>My application runs without problems when I create directory <code>\/usr\/local\/lib<\/code> and a symbolic link to the library.<\/p>\n<p><code>man dydl<\/code> tells about three related environment variables:<\/p>\n<ul>\n<li><code>DYLD_LIBRARY_PATH<\/code><\/li>\n<li><code>DYLD_FALLBACK_FRAMEWORK_PATH<\/code><\/li>\n<li><code>DYLD_FALLBACK_LIBRARY_PATH<\/code><\/li>\n<\/ul>\n<p>I know how to set the variables on a bash terminal (see e.g. Where do I set DYLD_LIBRARY_PATH on Mac OS X, and is it a good idea?), but how do I set environment variables for Xcode ?<\/p>\n<p>I&#8217;m running OS X 10.8.x and Xcode 4.5.x.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my Cocoa application I&#8217;m using a third party C-library that is compiled in command line and available in a custom location. In my Xcode project I can define where the library&#8217;s header files are located and where the library is looked during linking: Header files location (HEADER_SEARCH_PATHS): Target &gt; Build Settings &gt; Search Paths [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4030","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4030"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4030\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}