0

I downloaded the SDK on Linux and copied the required files into the directory of the file I wanted to run. However, every time I try to compile my program, it gives me this error:

    /tmp/ccWcnfz5.o: In function `SampleListener::onConnect(Leap::Controller const&)':
    Sample.cpp:(.text+0x6c): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0x82): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0x98): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0xae): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    /tmp/ccWcnfz5.o: In function `SampleListener::onFrame(Leap::Controller const&)':
    Sample.cpp:(.text+0x14c): undefined reference to `Leap::Controller::frame(int) const'
    Sample.cpp:(.text+0x165): undefined reference to `Leap::Frame::gestures() const'
    Sample.cpp:(.text+0x174): undefined reference to `Leap::GestureList::count() const'
    Sample.cpp:(.text+0x18f): undefined reference to `Leap::Frame::tools() const'
    Sample.cpp:(.text+0x19e): undefined reference to `Leap::ToolList::count() const'
    Sample.cpp:(.text+0x1ba): undefined reference to `Leap::Frame::fingers() const'
    Sample.cpp:(.text+0x1d3): undefined reference to `Leap::FingerList::extended() const'
    Sample.cpp:(.text+0x1e2): undefined reference to `Leap::FingerList::count() const'
    Sample.cpp:(.text+0x1fe): undefined reference to `Leap::Frame::hands() const'
    Sample.cpp:(.text+0x20d): undefined reference to `Leap::HandList::count() const'
    Sample.cpp:(.text+0x21f): undefined refe g++ Sample.cpp -o Sample
    /tmp/ccWcnfz5.o: In function `SampleListener::onConnect(Leap::Controller const&)':
    Sample.cpp:(.text+0x6c): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0x82): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0x98): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    Sample.cpp:(.text+0xae): undefined reference to `Leap::Controller::enableGesture(Leap::Gesture::Type, bool) const'
    /tmp/ccWcnfz5.o: In function `SampleListener::onFrame(Leap::Controller const&)':
    Sample.cpp:(.text+0x14c): undefined reference to `Leap::Controller::frame(int) const'
    Sample.cpp:(.text+0x165): undefined reference to `Leap::Frame::gestures() const'
    Sample.cpp:(.text+0x174): undefined reference to 
    /tmp/ccWcnfz5.o: In function `Leap::Device::toString() const':
    Sample.cpp:(.text._ZNK4Leap6Device8toStringEv[_ZNK4Leap6Device8toStringEv]+0x19): undefined reference to `Leap::Device::toCString() const'
    Sample.cpp:(.text._ZNK4Leap6Device8toStringEv[_ZNK4Leap6Device8toStringEv]+0x58): undefined reference to `Leap::Interface::deleteCString(char const*)'
    /tmp/ccWcnfz5.o: In function `Leap::Pointable::~Pointable()':
    Sample.cpp:(.text._ZN4Leap9PointableD2Ev[_ZN4Leap9PointableD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::Gesture::~Gesture()':
    Sample.cpp:(.text._ZN4Leap7GestureD2Ev[_ZN4Leap7GestureD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::HandList, Leap::Hand>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv[_ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv]+0x29): undefined reference to `Leap::HandList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::FingerList, Leap::Finger>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv[_ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv]+0x29): undefined reference to `Leap::FingerList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::ToolList, Leap::Tool>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_8ToolListENS_4ToolEEdeEv[_ZNK4Leap17ConstListIteratorINS_8ToolListENS_4ToolEEdeEv]+0x29): undefined reference to `Leap::ToolList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::Frame::~Frame()':
    Sample.cpp:(.text._ZN4Leap5FrameD2Ev[_ZN4Leap5FrameD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::DeviceList::~DeviceList()':
    Sample.cpp:(.text._ZN4Leap10DeviceListD2Ev[_ZN4Leap10DeviceListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::GestureList::~GestureList()':
    Sample.cpp:(.text._ZN4Leap11GestureListD2Ev[_ZN4Leap11GestureListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::HandList::~HandList()':
    Sample.cpp:(.text._ZN4Leap8HandListD2Ev[_ZN4Leap8HandListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::ToolList::~ToolList()':
    Sample.cpp:(.text._ZN4Leap8ToolListD2Ev[_ZN4Leap8ToolListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o:Sample.cpp:(.text._ZN4Leap10FingerListD2Ev[_ZN4Leap10FingerListD5Ev]+0x1f): more undefined references to `Leap::Interface::~Interface()' follow
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap5FrameE[_ZTIN4Leap5FrameE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap10DeviceListE[_ZTIN4Leap10DeviceListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap11GestureListE[_ZTIN4Leap11GestureListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap8HandListE[_ZTIN4Leap8HandListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap8ToolListE[_ZTIN4Leap8ToolListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap10FingerListE[_ZTIN4Leap10FingerListE]+0x10): more undefined references to `typeinfo for Leap::Interface' follow
    /tmp/ccWcnfz5.o: In function `Leap::Device::~Device()':
    Sample.cpp:(.text._ZN4Leap6DeviceD2Ev[_ZN4Leap6DeviceD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap6DeviceE[_ZTIN4Leap6DeviceE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    collect2: error: ld returned 1 exit status
    anthony@anthony-VGN-NW240F:~/Documents/Programming/Leap-Motion/LeapDeveloperKit_2.2.2+24469_linux/LeapSDK/samples/C++$ 
    rence to `Leap::Frame::timestamp() const'
    Sample.cpp:(.text+0x231): undefined reference to `Leap::Frame::id() const'
    Sample.cpp:(.text+0x33e): undefined reference to `Leap::Frame::hands() const'
    Sample.cpp:(.text+0x34d): undefined reference to `Leap::HandList::begin() const'
    Sample.cpp:(.text+0x394): undefined reference to `Leap::Hand::isLeft() const'
    Sample.cpp:(.text+0x3dc): undefined reference to `Leap::Hand::palmPosition() const'
    Sample.cpp:(.text+0x3eb): undefined reference to `Leap::Hand::id() const'
    Sample.cpp:(.text+0x4b3): undefined reference to `Leap::Hand::palmNormal() const'
    Sample.cpp:(.text+0x4cc): undefined reference to `Leap::Hand::direction() const'
    Sample.cpp:(.text+0x631): undefined reference to `Leap::Hand::arm() const'
    Sample.cpp:(.text+0x644): undefined reference to `Leap::Arm::elbowPosition() const'
    Sample.cpp:(.text+0x657): undefined reference to `Leap::Arm::wristPosition() const'
    Sample.cpp:(.text+0x66a): undefined reference to `Leap::Arm::direction() const'
    Sample.cpp:(.text+0x73c): undefined reference to `Leap::Hand::fingers() const'
    Sample.cpp:(.text+0x748): undefined reference to `Leap::FingerList::begin() const'
    Sample.cpp:(.text+0x774): undefined reference to `Leap::Pointable::width() const'
    Sample.cpp:(.text+0x78e): undefined reference to `Leap::Pointable::length() const'
    Sample.cpp:(.text+0x7a9): undefined reference to `Leap::Pointable::id() const'
    Sample.cpp:(.text+0x7b8): undefined reference to `Leap::Finger::type() const'
    Sample.cpp:(.text+0x8cb): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
    Sample.cpp:(.text+0x8e1): undefined reference to `Leap::Bone::direction() const'
    Sample.cpp:(.text+0x8f7): undefined reference to `Leap::Bone::nextJoint() const'
    Sample.cpp:(.text+0x90d): undefined reference to `Leap::Bone::prevJoint() const'
    Sample.cpp:(.text+0xa3d): undefined reference to `Leap::FingerList::end() const'
    Sample.cpp:(.text+0xabd): undefined reference to `Leap::HandList::end() const'
    Sample.cpp:(.text+0xb05): undefined reference to `Leap::Frame::tools() const'
    Sample.cpp:(.text+0xb14): undefined reference to `Leap::ToolList::begin() const'
    Sample.cpp:(.text+0xb47): undefined reference to `Leap::Pointable::direction() const'
    Sample.cpp:(.text+0xb5a): undefined reference to `Leap::Pointable::tipPosition() const'
    Sample.cpp:(.text+0xb66): undefined reference to `Leap::Pointable::id() const'
    Sample.cpp:(.text+0xc46): undefined reference to `Leap::ToolList::end() const'
    Sample.cpp:(.text+0xc82): undefined reference to `Leap::Frame::gestures() const'
    Sample.cpp:(.text+0xcb0): undefined reference to `Leap::GestureList::operator[](int) const'
    Sample.cpp:(.text+0xcbf): undefined reference to `Leap::Gesture::type() const'
    Sample.cpp:(.text+0xd04): undefined reference to `Leap::CircleGesture::CircleGesture(Leap::Gesture const&)'
    Sample.cpp:(.text+0xd26): undefined reference to `Leap::CircleGesture::normal() const'
    Sample.cpp:(.text+0xd39): undefined reference to `Leap::CircleGesture::pointable() const'
    Sample.cpp:(.text+0xd4f): undefined reference to `Leap::Pointable::direction() const'
    Sample.cpp:(.text+0xdc5): undefined reference to `Leap::Gesture::state() const'
    Sample.cpp:(.text+0xddf): undefined reference to `Leap::Gesture::id() const'
    Sample.cpp:(.text+0xdfc): undefined reference to `Leap::Controller::frame(int) const'
    Sample.cpp:(.text+0xe11): undefined reference to `Leap::Frame::gesture(int) const'
    Sample.cpp:(.text+0xe24): undefined reference to `Leap::CircleGesture::CircleGesture(Leap::Gesture const&)'
    Sample.cpp:(.text+0xe48): undefined reference to `Leap::CircleGesture::progress() const'
    Sample.cpp:(.text+0xe5c): undefined reference to `Leap::CircleGesture::progress() const'
    Sample.cpp:(.text+0xeb7): undefined reference to `Leap::CircleGesture::radius() const'
    Sample.cpp:(.text+0xed1): undefined reference to `Leap::CircleGesture::progress() const'
    Sample.cpp:(.text+0xeef): undefined reference to `Leap::Gesture::state() const'
    Sample.cpp:(.text+0xf0b): undefined reference to `Leap::Gesture::id() const'
    Sample.cpp:(.text+0x1060): undefined reference to `Leap::SwipeGesture::SwipeGesture(Leap::Gesture const&)'
    Sample.cpp:(.text+0x106c): undefined reference to `Leap::SwipeGesture::speed() const'
    Sample.cpp:(.text+0x108d): undefined reference to `Leap::SwipeGesture::direction() const'
    Sample.cpp:(.text+0x109c): undefined reference to `Leap::Gesture::state() const'
    Sample.cpp:(.text+0x10b8): undefined reference to `Leap::Gesture::id() const'
    Sample.cpp:(.text+0x11ba): undefined reference to `Leap::KeyTapGesture::KeyTapGesture(Leap::Gesture const&)'
    Sample.cpp:(.text+0x11cd): undefined reference to `Leap::KeyTapGesture::direction() const'
    Sample.cpp:(.text+0x11e0): undefined reference to `Leap::KeyTapGesture::position() const'
    Sample.cpp:(.text+0x11ef): undefined reference to `Leap::Gesture::state() const'
    Sample.cpp:(.text+0x120b): undefined reference to `Leap::Gesture::id() const'
    Sample.cpp:(.text+0x1304): undefined reference to `Leap::ScreenTapGesture::ScreenTapGesture(Leap::Gesture const&)'
    Sample.cpp:(.text+0x1317): undefined reference to `Leap::ScreenTapGesture::direction() const'
    Sample.cpp:(.text+0x132a): undefined reference to `Leap::ScreenTapGesture::position() const'
    Sample.cpp:(.text+0x1339): undefined reference to `Leap::Gesture::state() const'
    Sample.cpp:(.text+0x1355): undefined reference to `Leap::Gesture::id() const'
    Sample.cpp:(.text+0x14d0): undefined reference to `Leap::GestureList::count() const'
    Sample.cpp:(.text+0x14fc): undefined reference to `Leap::Frame::hands() const'
    Sample.cpp:(.text+0x150d): undefined reference to `Leap::HandList::isEmpty() const'
    Sample.cpp:(.text+0x1523): undefined reference to `Leap::GestureList::isEmpty() const'
    /tmp/ccWcnfz5.o: In function `SampleListener::onDeviceChange(Leap::Controller const&)':
    Sample.cpp:(.text+0x1a3c): undefined reference to `Leap::Controller::devices() const'
    Sample.cpp:(.text+0x1a5e): undefined reference to `Leap::DeviceList::operator[](int) const'
    Sample.cpp:(.text+0x1aca): undefined reference to `Leap::DeviceList::operator[](int) const'
    Sample.cpp:(.text+0x1ad6): undefined reference to `Leap::Device::isStreaming() const'
    Sample.cpp:(.text+0x1b29): undefined reference to `Leap::DeviceList::count() const'
    /tmp/ccWcnfz5.o: In function `main':
    Sample.cpp:(.text+0x1c1e): undefined reference to `Leap::Controller::Controller()'
    Sample.cpp:(.text+0x1c31): undefined reference to `Leap::Controller::addListener(Leap::Listener&)'
    Sample.cpp:(.text+0x1c64): undefined reference to `Leap::Controller::setPolicy(Leap::Controller::PolicyFlag) const'
    Sample.cpp:(.text+0x1c9d): undefined reference to `Leap::Controller::removeListener(Leap::Listener&)'
    Sample.cpp:(.text+0x1cae): undefined reference to `Leap::Controller::~Controller()'
    Sample.cpp:(.text+0x1ccd): undefined reference to `Leap::Controller::~Controller()'
    /tmp/ccWcnfz5.o: In function `Leap::Device::toString() const':
    Sample.cpp:(.text._ZNK4Leap6Device8toStringEv[_ZNK4Leap6Device8toStringEv]+0x19): undefined reference to `Leap::Device::toCString() const'
    Sample.cpp:(.text._ZNK4Leap6Device8toStringEv[_ZNK4Leap6Device8toStringEv]+0x58): undefined reference to `Leap::Interface::deleteCString(char const*)'
    /tmp/ccWcnfz5.o: In function `Leap::Pointable::~Pointable()':
    Sample.cpp:(.text._ZN4Leap9PointableD2Ev[_ZN4Leap9PointableD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::Gesture::~Gesture()':
    Sample.cpp:(.text._ZN4Leap7GestureD2Ev[_ZN4Leap7GestureD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::HandList, Leap::Hand>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv[_ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv]+0x29): undefined reference to `Leap::HandList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::FingerList, Leap::Finger>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv[_ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv]+0x29): undefined reference to `Leap::FingerList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::ConstListIterator<Leap::ToolList, Leap::Tool>::operator*() const':
    Sample.cpp:(.text._ZNK4Leap17ConstListIteratorINS_8ToolListENS_4ToolEEdeEv[_ZNK4Leap17ConstListIteratorINS_8ToolListENS_4ToolEEdeEv]+0x29): undefined reference to `Leap::ToolList::operator[](int) const'
    /tmp/ccWcnfz5.o: In function `Leap::Frame::~Frame()':
    Sample.cpp:(.text._ZN4Leap5FrameD2Ev[_ZN4Leap5FrameD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::DeviceList::~DeviceList()':
    Sample.cpp:(.text._ZN4Leap10DeviceListD2Ev[_ZN4Leap10DeviceListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::GestureList::~GestureList()':
    Sample.cpp:(.text._ZN4Leap11GestureListD2Ev[_ZN4Leap11GestureListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::HandList::~HandList()':
    Sample.cpp:(.text._ZN4Leap8HandListD2Ev[_ZN4Leap8HandListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o: In function `Leap::ToolList::~ToolList()':
    Sample.cpp:(.text._ZN4Leap8ToolListD2Ev[_ZN4Leap8ToolListD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o:Sample.cpp:(.text._ZN4Leap10FingerListD2Ev[_ZN4Leap10FingerListD5Ev]+0x1f): more undefined references to `Leap::Interface::~Interface()' follow
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap5FrameE[_ZTIN4Leap5FrameE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap10DeviceListE[_ZTIN4Leap10DeviceListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap11GestureListE[_ZTIN4Leap11GestureListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap8HandListE[_ZTIN4Leap8HandListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap8ToolListE[_ZTIN4Leap8ToolListE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap10FingerListE[_ZTIN4Leap10FingerListE]+0x10): more undefined references to `typeinfo for Leap::Interface' follow
    /tmp/ccWcnfz5.o: In function `Leap::Device::~Device()':
    Sample.cpp:(.text._ZN4Leap6DeviceD2Ev[_ZN4Leap6DeviceD5Ev]+0x1f): undefined reference to `Leap::Interface::~Interface()'
    /tmp/ccWcnfz5.o:(.rodata._ZTIN4Leap6DeviceE[_ZTIN4Leap6DeviceE]+0x10): undefined reference to `typeinfo for Leap::Interface'
    collect2: error: ld returned 1 exit status

Code:

#include <iostream>
#include <string.h>
#include "Leap.h"

using namespace Leap;


class SampleListener : public Listener {
  public:
    virtual void onInit(const Controller&);
    virtual void onConnect(const Controller&);
    virtual void onDisconnect(const Controller&);
    virtual void onExit(const Controller&);
    virtual void onFrame(const Controller&);
    virtual void onFocusGained(const Controller&);
    virtual void onFocusLost(const Controller&);
    virtual void onDeviceChange(const Controller&);
    virtual void onServiceConnect(const Controller&);
    virtual void onServiceDisconnect(const Controller&);

  private:
};

const std::string fingerNames[] = {"Thumb", "Index", "Middle", "Ring", "Pinky"};
const std::string boneNames[] = {"Metacarpal", "Proximal", "Middle", "Distal"};
const std::string stateNames[] = {"STATE_INVALID", "STATE_START", "STATE_UPDATE", "STATE_END"};

void SampleListener::onInit(const Controller& controller) {
  std::cout << "Initialized" << std::endl;
}

void SampleListener::onConnect(const Controller& controller) {
  std::cout << "Connected" << std::endl;
  controller.enableGesture(Gesture::TYPE_CIRCLE);
  controller.enableGesture(Gesture::TYPE_KEY_TAP);
  controller.enableGesture(Gesture::TYPE_SCREEN_TAP);
  controller.enableGesture(Gesture::TYPE_SWIPE);
}

void SampleListener::onDisconnect(const Controller& controller) {
  // Note: not dispatched when running in a debugger.
  std::cout << "Disconnected" << std::endl;
}

void SampleListener::onExit(const Controller& controller) {
  std::cout << "Exited" << std::endl;
}

void SampleListener::onFrame(const Controller& controller) {
  // Get the most recent frame and report some basic information
  const Frame frame = controller.frame();
  std::cout << "Frame id: " << frame.id()
            << ", timestamp: " << frame.timestamp()
            << ", hands: " << frame.hands().count()
            << ", extended fingers: " << frame.fingers().extended().count()
            << ", tools: " << frame.tools().count()
            << ", gestures: " << frame.gestures().count() << std::endl;

  HandList hands = frame.hands();
  for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
    // Get the first hand
    const Hand hand = *hl;
    std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
    std::cout << std::string(2, ' ') << handType << ", id: " << hand.id()
              << ", palm position: " << hand.palmPosition() << std::endl;
    // Get the hand's normal vector and direction
    const Vector normal = hand.palmNormal();
    const Vector direction = hand.direction();

    // Calculate the hand's pitch, roll, and yaw angles
    std::cout << std::string(2, ' ') <<  "pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
              << "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
              << "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;

    // Get the Arm bone
    Arm arm = hand.arm();
    std::cout << std::string(2, ' ') <<  "Arm direction: " << arm.direction()
              << " wrist position: " << arm.wristPosition()
              << " elbow position: " << arm.elbowPosition() << std::endl;

    // Get fingers
    const FingerList fingers = hand.fingers();
    for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
      const Finger finger = *fl;
      std::cout << std::string(4, ' ') <<  fingerNames[finger.type()]
                << " finger, id: " << finger.id()
                << ", length: " << finger.length()
                << "mm, width: " << finger.width() << std::endl;

      // Get finger bones
      for (int b = 0; b < 4; ++b) {
        Bone::Type boneType = static_cast<Bone::Type>(b);
        Bone bone = finger.bone(boneType);
        std::cout << std::string(6, ' ') <<  boneNames[boneType]
                  << " bone, start: " << bone.prevJoint()
                  << ", end: " << bone.nextJoint()
                  << ", direction: " << bone.direction() << std::endl;
      }
    }
  }

  // Get tools
  const ToolList tools = frame.tools();
  for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
    const Tool tool = *tl;
    std::cout << std::string(2, ' ') <<  "Tool, id: " << tool.id()
              << ", position: " << tool.tipPosition()
              << ", direction: " << tool.direction() << std::endl;
  }

  // Get gestures
  const GestureList gestures = frame.gestures();
  for (int g = 0; g < gestures.count(); ++g) {
    Gesture gesture = gestures[g];

    switch (gesture.type()) {
      case Gesture::TYPE_CIRCLE:
      {
        CircleGesture circle = gesture;
        std::string clockwiseness;

        if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
          clockwiseness = "clockwise";
        } else {
          clockwiseness = "counterclockwise";
        }

        // Calculate angle swept since last frame
        float sweptAngle = 0;
        if (circle.state() != Gesture::STATE_START) {
          CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
          sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
        }
        std::cout << std::string(2, ' ')
                  << "Circle id: " << gesture.id()
                  << ", state: " << stateNames[gesture.state()]
                  << ", progress: " << circle.progress()
                  << ", radius: " << circle.radius()
                  << ", angle " << sweptAngle * RAD_TO_DEG
                  <<  ", " << clockwiseness << std::endl;
        break;
      }
      case Gesture::TYPE_SWIPE:
      {
        SwipeGesture swipe = gesture;
        std::cout << std::string(2, ' ')
          << "Swipe id: " << gesture.id()
          << ", state: " << stateNames[gesture.state()]
          << ", direction: " << swipe.direction()
          << ", speed: " << swipe.speed() << std::endl;
        break;
      }
      case Gesture::TYPE_KEY_TAP:
      {
        KeyTapGesture tap = gesture;
        std::cout << std::string(2, ' ')
          << "Key Tap id: " << gesture.id()
          << ", state: " << stateNames[gesture.state()]
          << ", position: " << tap.position()
          << ", direction: " << tap.direction()<< std::endl;
        break;
      }
      case Gesture::TYPE_SCREEN_TAP:
      {
        ScreenTapGesture screentap = gesture;
        std::cout << std::string(2, ' ')
          << "Screen Tap id: " << gesture.id()
          << ", state: " << stateNames[gesture.state()]
          << ", position: " << screentap.position()
          << ", direction: " << screentap.direction()<< std::endl;
        break;
      }
      default:
        std::cout << std::string(2, ' ')  << "Unknown gesture type." << std::endl;
        break;
    }
  }

  if (!frame.hands().isEmpty() || !gestures.isEmpty()) {
    std::cout << std::endl;
  }
}

void SampleListener::onFocusGained(const Controller& controller) {
  std::cout << "Focus Gained" << std::endl;
}

void SampleListener::onFocusLost(const Controller& controller) {
  std::cout << "Focus Lost" << std::endl;
}

void SampleListener::onDeviceChange(const Controller& controller) {
  std::cout << "Device Changed" << std::endl;
  const DeviceList devices = controller.devices();

  for (int i = 0; i < devices.count(); ++i) {
    std::cout << "id: " << devices[i].toString() << std::endl;
    std::cout << "  isStreaming: " << (devices[i].isStreaming() ? "true" : "false") << std::endl;
  }
}

void SampleListener::onServiceConnect(const Controller& controller) {
  std::cout << "Service Connected" << std::endl;
}

void SampleListener::onServiceDisconnect(const Controller& controller) {
  std::cout << "Service Disconnected" << std::endl;
}

int main(int argc, char** argv) {
  // Create a sample listener and controller
  SampleListener listener;
  Controller controller;

  // Have the sample listener receive events from the controller
  controller.addListener(listener);

  if (argc > 1 && strcmp(argv[1], "--bg") == 0)
    controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);

  // Keep this process running until Enter is pressed
  std::cout << "Press Enter to quit..." << std::endl;
  std::cin.get();

  // Remove the sample listener when done
  controller.removeListener(listener);

  return 0;
}

How would I fix this?

user3377126
  • 2,091
  • 4
  • 32
  • 39
  • How are you compiling this? Are you linking to Leap's library? – Cornstalks Jan 18 '15 at 06:47
  • I am compiling this through the terminal by using "g++ Sample.cpp -o Sample" and I downloaded Leap's library (I think I did at least) . – user3377126 Jan 18 '15 at 07:01
  • @user3377126 Installing the library is not enough; you need to link to the library at compilation time. – cdhowie Jan 18 '15 at 07:37
  • How do I link to the library? I kind of used this source code that was already in the Linux Leap Motion SDK. Are you saying that the code is correct and that it would experience no compiling problems if the library was linked? – user3377126 Jan 18 '15 at 07:39
  • There is a make file in the SDK that will compile and link the sample program for you. Otherwise, you can add the path to the correct library (in the lib folder -- either x86 for 32-bit or x64 for 64-bit). To run the program, you can either copy the libraries to the same folder as your program, or use the install_name_tool to make your program look for these libraries somewhere else. The make file also has an example for this second step. – Charles Ward Jan 19 '15 at 19:18

0 Answers0