Ok so I think I narrowed the error. I started doing again the Hello World following the instructions here Hello World. There is no problem to compile the basic hello world program:
#include <iostream>
#include <string.h>
#include "Leap.h"
using namespace Leap;
int main(int argc, char** argv) {
// Keep this process running until Enter is pressed
std::cout << "Press Enter to quit..." << std::endl;
std::cin.get();
return 0;
}
This works ok. But when I add the listener and controller, the problem starts. Here is the code that I wrote, following the instructions in the Hello World:
#include <iostream>
#include <cstring>
#include "Leap.h"
using namespace Leap;
class Escuchador : public Listener {
public:
virtual void onConnect(const Controller&);
virtual void onFrame(const Controller&);
};
void Escuchador::onConnect(const Controller& controlador) {
std::cout << "Conectado" << std::endl;
}
void Escuchador::onFrame(const Controller& controlador) {
const Frame frame = controlador.frame();
std::cout << "Frame id: " << frame.id()
<< ", Marca Temporal:" << frame.timestamp()
<< ", Manos: " << frame.hands().count()
<< ", Dedos: " << frame.fingers().count() << std::endl;
}
int main(int argc, char** argv) {
Escuchador listener;
Controller controlador;
controlador.addListener(listener);
std::cout << "Presiona ENTER para salir" << std::endl;
std::cin.get();
controlador.removeListener(listener);
return 0;
}
When I try to compile it, I get this on the terminal:
g++ -std=c++0x -std=c++0x Programa.cpp -o Programa
/tmp/cczRPVZm.o: In function `Escuchador::onFrame(Leap::Controller const&)':
Programa.cpp:(.text+0x4b): undefined reference to `Leap::Controller::frame(int) const'
Programa.cpp:(.text+0x60): undefined reference to `Leap::Frame::fingers() const'
Programa.cpp:(.text+0x6e): undefined reference to `Leap::FingerList::count() const'
Programa.cpp:(.text+0x82): undefined reference to `Leap::Frame::hands() const'
Programa.cpp:(.text+0x90): undefined reference to `Leap::HandList::count() const'
Programa.cpp:(.text+0x9e): undefined reference to `Leap::Frame::timestamp() const'
Programa.cpp:(.text+0xad): undefined reference to `Leap::Frame::id() const'
/tmp/cczRPVZm.o: In function `main':
Programa.cpp:(.text+0x1ca): undefined reference to `Leap::Controller::Controller()'
Programa.cpp:(.text+0x1de): undefined reference to `Leap::Controller::addListener(Leap::Listener&)'
Programa.cpp:(.text+0x222): undefined reference to `Leap::Controller::removeListener(Leap::Listener&)'
Programa.cpp:(.text+0x233): undefined reference to `Leap::Controller::~Controller()'
Programa.cpp:(.text+0x251): undefined reference to `Leap::Controller::~Controller()'
/tmp/cczRPVZm.o: In function `Leap::Frame::~Frame()':
Programa.cpp:(.text._ZN4Leap5FrameD2Ev[_ZN4Leap5FrameD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cczRPVZm.o:(.rodata._ZTIN4Leap5FrameE[_ZTIN4Leap5FrameE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cczRPVZm.o: In function `Leap::HandList::~HandList()':
Programa.cpp:(.text._ZN4Leap8HandListD2Ev[_ZN4Leap8HandListD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cczRPVZm.o: In function `Leap::FingerList::~FingerList()':
Programa.cpp:(.text._ZN4Leap10FingerListD2Ev[_ZN4Leap10FingerListD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cczRPVZm.o:(.rodata._ZTIN4Leap8HandListE[_ZTIN4Leap8HandListE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cczRPVZm.o:(.rodata._ZTIN4Leap10FingerListE[_ZTIN4Leap10FingerListE]+0x8): undefined reference to `typeinfo for Leap::Interface'
collect2: error: ld returned 1 exit status
make: *** [Programa] Error 1
And here is my makefile, its almost the same as the sample one, because im using the same file format (for compiling, I move my Programa.cpp int /samples/ folder; the basic hello world compiled and runs great doing that way).
OS := $(shell uname)
ARCH := $(shell uname -m)
CXXFLAGS := -std=c++0x -std=c++0x
ifeq ($(OS), Linux)
ifeq ($(ARCH), x86_64)
LEAP_LIBRARY := ../lib/x64/libLeap.so -Wl,-rpath,../lib/x64
else
LEAP_LIBRARY := ../lib/x86/libLeap.so -Wl,-rpath,../lib/x86
endif
else
# OS X
LEAP_LIBRARY := ../lib/libLeap.dylib
endif
Sample: Sample.cpp
$(CXX) -Wall -g -I../include Sample.cpp -o Sample $(LEAP_LIBRARY)
ifeq ($(OS), Darwin)
install_name_tool -change @loader_path/libLeap.dylib ../lib/libLeap.dylib Sample
endif
clean:
rm -rf Sample Sample.dSYM
The only line I added to the makefile was this one: CXXFLAGS := -std=c++0x -std=c++0x
just for solving a C+98 compiling problem. So I dont understand why I am getting that error in linux when trying to compile, can anyone help me? Thanks!
P.D: Im using the 2.3.1+31549 SDK