File size: 6,476 Bytes
d4035c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
<!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>
<!-- Stylesheets -->
<link href="web.css" type="text/css" rel="stylesheet"></link>
<title>VLFeat - Download - C library install - Using Xcode</title>
<!-- Scripts-->
</meta>
<!-- Body Start -->
<body>
<div id="header">
<!-- Google CSE Search Box Begins -->
<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>
<!-- Google CSE Search Box Ends -->
<h1>VLFeat.org</h1>
</div>
<div id="headbanner">
Download - C library install - Using Xcode
</div>
<div id="pagebody">
<div id="sidebar"> <!-- Navigation Start -->
<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> <!-- sidebar -->
<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> <!-- pagebody -->
<div id="footer">
© 2005-09 Andrea Vedaldi and Brian Fulkerson
</div> <!-- footer -->
<!-- Google Analytics Begins -->
<script xml:space="preserve" type="text/javascript">
//<![CDATA[
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">
//<![CDATA[
var localre = /vlfeat.org/;
if(document.location.host.search(localre) != -1)
{
try {
var pageTracker = _gat._getTracker("UA-4936091-2");
pageTracker._trackPageview();
} catch(err) {}
}
//]]>
</script>
<!-- Google Analytics Ends -->
</body>
</html>
|