| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
|
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <meta> |
| |
| <link href="web.css" type="text/css" rel="stylesheet"></link> |
| <title>VLFeat - Download - C library install - Using Xcode</title> |
| |
| |
| |
| |
| </meta> |
| |
| |
| <body> |
| <div id="header"> |
| |
| <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded"> |
| <div> |
| <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input> |
| <input type="hidden" name="cof" value="FORID:11"></input> |
| <input type="hidden" name="ie" value="UTF-8"></input> |
| <input type="text" name="q" size="31"></input> |
| <input type="submit" name="sa" value="Search"></input> |
| </div> |
| </form> |
| <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en" xml:space="preserve" type="text/javascript"></script> |
| |
| <h1>VLFeat.org</h1> |
| </div> |
| <div id="headbanner"> |
| Download - C library install - Using Xcode |
| </div> |
| <div id="pagebody"> |
| <div id="sidebar"> |
| <ul> |
| <li><a href="index.html">Home</a> |
| </li> |
| <li><a href="download.html">Download</a> |
| <ul> |
| <li><a href="install-matlab.html">Matlab install</a> |
| </li> |
| <li><a href="install-shell.html">Shell install</a> |
| </li> |
| <li><a href="install-c.html">C library install</a> |
| <ul> |
| <li><a href="xcode.html" class='active' >Using Xcode</a> |
| </li> |
| <li><a href="vsexpress.html">Using VC++</a> |
| </li> |
| </ul></li> |
| <li><a href="compiling.html">Compiling</a> |
| </li> |
| </ul></li> |
| <li><a href="doc.html">Documentation</a> |
| </li> |
| <li><a href="overview/tut.html">Tutorials</a> |
| </li> |
| </ul> |
|
|
| </div> |
| <div id="content"> |
| |
|
|
| <p>These instructions show how to setup a basic <b>VLFeat</b> project |
| with Apple Xcode. For the sake of simplicty, we create a command |
| line tool written in C. However, these steps apply with minor |
| modifications to other project types and to the C++ lanuage.</p> |
|
|
| <p>First, let us create a new project |
| called <code>vlfeat-client</code>. Open Xcode and select <b>File |
| > New Project > Command Line Utility > Standard Tool</b> |
| and click <b>Choose</b>. Give a name to your project (in our |
| case <code>vlfeat-client</code>), and click <b>Save</b>.</p> |
|
|
| <div class="figure"> |
| <img src="images/using-xcode-new.png" alt="Xcode new project"></img> |
| </div> |
|
|
| <p>Now we need to add <b>VLFeat</b> to the C compiler include search |
| path. To do this, select the <code>vlfeat-client</code> target and |
| open the information panel (the blue button, |
| or <b>Command-i</b>). Then select the <b>Build</b> panel, search for |
| the field <b>Header Search Paths</b>, and add |
| <b>VLFeat</b> root path (in our case this is |
| just <code>~/src/vlfeat</code>).</p> |
|
|
| <img src="images/using-xcode-info.png" alt="Xcode info"></img> |
|
|
| <p>Next, we add the <code>libvl.dylib</code> library file to the |
| project resources so that Xcode links against it. To do this, drag |
| and drop the <code>libvl.dylib</code> file (in our example |
| <code>~/src/vlfeat/bin/maci/libvl.dylib</code>) to the left panel and click |
| <b>Add</b>.</p> |
|
|
| <img src="images/using-xcode-dylib.png" alt="Xcode dylib"></img> |
|
|
| <p>Next, edit the <code>main.c</code> source file and type the following code:</p> |
|
|
| <pre xml:space="preserve"> |
| #include <vl/generic.h> |
|
|
| int main (int argc, const char * argv[]) { |
| VL_PRINT ("Hello world!") ; |
| return 0; |
| } |
| </pre> |
|
|
| <img src="images/using-xcode-edit.png" alt="Xcode edit"></img> |
|
|
| <p>If you try to build the project, it should compile without errors |
| (if you are using C++, do not forget to wrap the <code>include</code> |
| statements in a <code>extern "C" {}</code> block). However, if you try |
| to run the program, it will fail, complaining that it cannot find the |
| library image.</p> |
|
|
| <img src="images/using-xcode-err.png" alt="Xcode error"></img> |
|
|
| <p>The reason is that <code>libvl.dylib</code> is compiled with the |
| library <code>install_name</code> equal |
| to <code>@loader_path/libvl.dylib</code>. This causes the run-time |
| loader to look for the library in the same directory of the |
| executable. There are two ways around this problem: The first is to |
| install the library in a standard location |
| (e.g. <code>/usr/local/lib</code>) and use the <code>otool</code> |
| command to change the |
| library <code>install_name</code>. The other is to simply copy |
| the <code>libvl.dylib</code> file in the executable directory. Here we |
| demonstrate the second technique.</p> |
|
|
| <p>To copy <code>libvl.dylib</code> in the executable directory, we |
| add a <b>Copy Files</b> build phase to the project. Right-click |
| the <code>vlfeat-client</code> target in the project panel and select |
| <b>Add > New Build Phase > New Copy Files Build |
| Phase</b>. Select <b>Destination: Executables</b>. Then drag-and-drop |
| the <code>libvl.dylib</code> item from the panel to the <b>Copy |
| Files</b> build phase.</p> |
|
|
| <img src="images/using-xcode-copy.png" alt="Xcode copy"></img> |
| <img src="images/using-xcode-copy-2.png" alt="Xcode copy"></img> |
|
|
| <p>Now rebuild the project, and run it. It should run correctly, |
| and if you open the debugger console you should see this:</p> |
|
|
| <img src="images/using-xcode-ok.png" alt="Xcode ok"></img> |
|
|
|
|
| </div> |
| <div class="clear"> </div> |
| </div> |
| <div id="footer"> |
| © 2005-09 Andrea Vedaldi and Brian Fulkerson |
| </div> |
| |
| |
| <script xml:space="preserve" type="text/javascript"> |
| |
| var localre = /vlfeat.org/; |
| if(document.location.host.search(localre) != -1) |
| { |
| var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
| document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| } |
| |
| </script> |
| <script xml:space="preserve" type="text/javascript"> |
| |
| var localre = /vlfeat.org/; |
| if(document.location.host.search(localre) != -1) |
| { |
| |
| try { |
| var pageTracker = _gat._getTracker("UA-4936091-2"); |
| pageTracker._trackPageview(); |
| } catch(err) {} |
| |
| } |
| |
| </script> |
| |
| </body> |
| </html> |
|
|
| |