title: c++ bluez eclipse linker config
body: <p>I'm trying to add bluez library to my eclipse project on raspberry pi 3 (raspbian). This is what I've done:</p>
  
  <ol>
  <li>Bluez is already installed on raspberry pi 3 but i did not find the headers files so i followed this tutorial:</li>
  </ol>
  
  <p><a href="https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation" rel="nofollow">https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation</a></p>
  
  <p>Now in directory /usr/local/include/bluez-5.37/lib/bluetooth i've got <em>bluetooth.h, hci.h,</em> ...</p>
  
  <ol start="2">
  <li>On eclipse:</li>
  </ol>
  
  <p>Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes</p>
  
  <p>In Include paths (-l) i add: /usr/local/include/bluez-5.37/lib/bluetooth</p>
  
  <ol start="3">
  <li>On eclipse</li>
  </ol>
  
  <p>Project > Properties > C/C++ Build > Settings > GCC C++ Linker > Libraries</p>
  
  <p>In libraries (-l) i add: bluetooth</p>
  
  <p>In Library search path (-L) i add: /usr/local/lib</p>
  
  <blockquote>
    <blockquote>
      <p>This is the code that i'm <a href="http://people.csail.mit.edu/albert/bluez-intro/c404.html" rel="nofollow">trying to build</a></p>
    </blockquote>
  </blockquote>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;bluetooth.h&gt;
  #include &lt;hci.h&gt;
  #include &lt;hci_lib.h&gt;
  
  int main(int argc, char **argv)
  {
      inquiry_info *ii = NULL;
      int max_rsp, num_rsp;
      int dev_id, sock, len, flags;
      int i;
      char addr[19] = { 0 };
      char name[248] = { 0 };
  
      dev_id = hci_get_route(NULL);
      sock = hci_open_dev( dev_id );
      if (dev_id &lt; 0 || sock &lt; 0) {
          perror("opening socket");
          exit(1);
      }
  
      len  = 8;
      max_rsp = 255;
      flags = IREQ_CACHE_FLUSH;
      ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
  
      num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &amp;ii, flags);
      if( num_rsp &lt; 0 ) perror("hci_inquiry");
  
      for (i = 0; i &lt; num_rsp; i++) {
          ba2str(&amp;(ii+i)-&gt;bdaddr, addr);
          memset(name, 0, sizeof(name));
          if (hci_read_remote_name(sock, &amp;(ii+i)-&gt;bdaddr, sizeof(name),
              name, 0) &lt; 0)
          strcpy(name, "[unknown]");
          printf("%s  %s\n", addr, name);
      }
  
      free( ii );
      close( sock );
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <blockquote>
      <p>Headers are found but this is what console says:</p>
    </blockquote>
  </blockquote>
  
  <pre><code>02:25:09 **** Incremental Build of configuration Release for project ComputerVision ****
  make all 
  Building target: ComputerVision
  Invoking: GCC C++ Linker
  g++ -L/usr/local/lib -o "ComputerVision"  ./src/ComputerVision.o   -lopencv_core -lbluetooth -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
  /usr/bin/ld: cannot find -lbluetooth
  makefile:45: recipe for target 'ComputerVision' failed
  collect2: error: ld returned 1 exit status
  make: *** [ComputerVision] Error 1
  
  02:25:09 Build Finished (took 382ms)
  </code></pre>
  
  <p>Bit newbie on this things... any help plz? thanks!</p>