我要疯了...
我正在开发一个程序,用于从带有OpenNI和NiTE的Xtion Primesense传感器中读取关节坐标。我把程序分为三部分。主传感器sensorOpenNI.hpp和sensorOpenNI.cpp。现在,将各部分链接在一起时,我会遇到很多错误,说存在对某些NiTE功能的未定义引用。我正在使用Kubuntu和g ++。 NiTE和OpenNI库位于名为Include ...的目录中。
这是错误消息:
/tmp/ccrPQHEg.o:在函数openni::VideoFrameRef::release()': sensorOpenNI.cpp:(.text._ZN6openni13VideoFrameRef7releaseEv[openni::VideoFrameRef::release()]+0x18): undefined reference to
oniFrameRelease'中
/tmp/ccrPQHEg.o:在函数openni::VideoFrameRef::_setFrame(OniFrame*)': sensorOpenNI.cpp:(.text._ZN6openni13VideoFrameRef9_setFrameEP8OniFrame[openni::VideoFrameRef::_setFrame(OniFrame*)]+0x25): undefined reference to
oniFrameAddRef'中
/tmp/ccrPQHEg.o:在函数nite::UserTrackerFrameRef::release()': sensorOpenNI.cpp:(.text._ZN4nite19UserTrackerFrameRef7releaseEv[nite::UserTrackerFrameRef::release()]+0x24): undefined reference to
niteUserTrackerFrameRelease'中
/tmp/ccrPQHEg.o:在函数nite::UserTracker::create(openni::Device*)': sensorOpenNI.cpp:(.text._ZN4nite11UserTracker6createEPN6openni6DeviceE[nite::UserTracker::create(openni::Device*)]+0x13): undefined reference to
niteInitializeUserTracker'中
sensorOpenNI.cpp :(。text._ZN4nite11UserTracker6createEPN6openni6DeviceE [nite :: UserTracker :: create(openni :: Device *)] + 0x27):未定义对niteInitializeUserTrackerByDevice' /tmp/ccrPQHEg.o: In function
nite :: UserTracker :: destroy()'的引用:
sensorOpenNI.cpp :(。text._ZN4nite11UserTracker7destroyEv [nite :: UserTracker :: destroy()] + 0x1e):未定义对niteShutdownUserTracker' /tmp/ccrPQHEg.o: In function
nite :: UserTracker :: readFrame(nite :: UserTrackerFrameRef *)的引用”':
sensorOpenNI.cpp :(。text._ZN4nite11UserTracker9readFrameEPNS_19UserTrackerFrameRefE [nite :: UserTracker :: readFrame(nite :: UserTrackerFrameRef *)] + 0x1d):未定义对niteReadUserTrackerFrame' /tmp/ccrPQHEg.o: In function
nite :: UserTracker :: startSkeletonTracking(short)'的引用:
sensorOpenNI.cpp :(。text._ZN4nite11UserTracker21startSkeletonTrackingEs [nite :: UserTracker :: startSkeletonTracking(short)] + 0x1e):未定义对niteStartSkeletonTracking' /tmp/ccrPQHEg.o: In function
nite :: NiTE :: initialize()'的引用:
sensorOpenNI.cpp :(。text._ZN4nite4NiTE10initializeEv [nite :: NiTE :: initialize()] + 0x7):未定义对niteInitialize' collect2: ld returned 1 exit status patrick@ubuntu:~/Koerpersteuerung$ g++ -c sensorOpenNI.cpp sensorOpenNI.hpp -I Include/ patrick@ubuntu:~/Koerpersteuerung$ g++ mainSensor.cpp sensorOpenNI.o -I Include/ sensorOpenNI.o: In function
openni :: VideoFrameRef :: release()'的引用:
sensorOpenNI.cpp :(。text._ZN6openni13VideoFrameRef7releaseEv [openni :: VideoFrameRef :: release()] + 0x18):未定义对oniFrameRelease' sensorOpenNI.o: In function
openni :: VideoFrameRef :: _ setFrame(OniFrame *)'的引用:
sensorOpenNI.cpp :(。text._ZN6openni13VideoFrameRef9_setFrameEP8OniFrame [openni :: VideoFrameRef :: _ setFrame(OniFrame *)] + 0x25):未定义对oniFrameAddRef' sensorOpenNI.o: In function
nite :: UserTrackerFrameRef :: release()'的引用:
sensorOpenNI.cpp :(。text._ZN4nite19UserTrackerFrameRef7releaseEv [nite :: UserTrackerFrameRef :: release()] + 0x24):未定义对niteUserTrackerFrameRelease' sensorOpenNI.o: In function
nite :: UserTracker :: create(openni :: Device *)'的引用:
sensorOpenNI.cpp :(。text._ZN4nite11UserTracker6createEPN6openni6DeviceE [nite :: UserTracker :: create(openni :: Device *)] + 0x13):未定义对niteInitializeUserTracker' sensorOpenNI.cpp:(.text._ZN4nite11UserTracker6createEPN6openni6DeviceE[nite::UserTracker::create(openni::Device*)]+0x27): undefined reference to
niteInitializeUserTrackerByDevice'的引用
sensorOpenNI.o:在功能nite::UserTracker::destroy()': sensorOpenNI.cpp:(.text._ZN4nite11UserTracker7destroyEv[nite::UserTracker::destroy()]+0x1e): undefined reference to
niteShutdownUserTracker'中
sensorOpenNI.o:在功能nite::UserTracker::readFrame(nite::UserTrackerFrameRef*)': sensorOpenNI.cpp:(.text._ZN4nite11UserTracker9readFrameEPNS_19UserTrackerFrameRefE[nite::UserTracker::readFrame(nite::UserTrackerFrameRef*)]+0x1d): undefined reference to
niteReadUserTrackerFrame'中
sensorOpenNI.o:在功能nite::UserTracker::startSkeletonTracking(short)': sensorOpenNI.cpp:(.text._ZN4nite11UserTracker21startSkeletonTrackingEs[nite::UserTracker::startSkeletonTracking(short)]+0x1e): undefined reference to
niteStartSkeletonTracking'中
sensorOpenNI.o:在功能nite::NiTE::initialize()': sensorOpenNI.cpp:(.text._ZN4nite4NiTE10initializeEv[nite::NiTE::initialize()]+0x7): undefined reference to
niteInitialize'中
collect2:ld返回1退出状态
我这样叫g ++:
g++ -o test mainSensor.cpp sensorOpenNI.cpp -I Include/
最佳答案
尝试像这样复制库libOpenNI2.so和libNiTE2:
sudo cp ./OpenNI-Linux-x86-2.2/Redist/libOpenNI2.so /usr/local/lib
sudo cp ./NiTE-Linux-x86-2.2/Redist/libNiTE2.so /usr/local/lib
然后做
须藤ldconfig
现在通过添加-lOpenNI2 -lNiTE2来编译程序
关于c++ - OpenNI链接错误,很多 undefined reference ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15803322/