0

I try to use the OpenCV Interface of Raspicam (Version 0.1.3).

A minimal example won't compile:

Contents ofmain.cpp

#include <raspicam/raspicam_cv.h>
using namespace std;

int main ( int argc,char **argv ) {
    raspicam::RaspiCam_Cv Camera;

    return 0;
}

Minimal command to compile and link:

g++ main.cpp -o main -I/usr/local/include/ -lraspicam -lraspicam_cv

Throws this errors:

//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getContrast()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setExposure(raspicam::RASPICAM_EXPOSURE)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getId[abi:cxx11]() const'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setISO(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::grab()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::~Private_Impl()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setHeight(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setWidth(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setShutterSpeed(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setAWB(raspicam::RASPICAM_AWB)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setDefaults()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::initialize()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setVerticalFlip(bool)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setAWB_RB(float, float)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::getId[abi:cxx11]() const'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::Private_Impl()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setHeight(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getISO()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setContrast(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setBrightness(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setSaturation(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setWidth(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::release()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getSaturation()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getHeight()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setEncoding(raspicam::RASPICAM_ENCODING)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getImageBufferSize() const'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getBrightness()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::getWidth()'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::retrieve(unsigned char*, raspicam::RASPICAM_FORMAT)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setBrightness(unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::open(bool)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setContrast(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setSaturation(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::setISO(int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl_Still::takePicture(unsigned char*, unsigned int)'
//usr/local/lib/libraspicam_cv.so: undefined reference to `raspicam::_private::Private_Impl::setFormat(raspicam::RASPICAM_FORMAT)'
collect2: error: ld returned 1 exit status

What is the problem? How do I solve it?

  • If you have issues with this question state them here instead of just downvoting. That feedback has no information value. Ty – xaedes Jun 2 '17 at 13:55
1

The problem was within the build process of raspicam itself.

raspicam_cv does not link against the object files of its source code. raspicam does link against those.

The solution is to change the CMakeLists.txt of raspicam and link against the object files, or simply against raspicam.

In raspicam-0.1.3/src/CMakeLists.txt line 41:

TARGET_LINK_LIBRARIES(${PROJECT_NAME}_cv ${PROJECT_NAME} ${REQUIRED_LIBRARIES}  ${OpenCV_LIBS} )

The ${PROJECT_NAME} (which is just raspicam) was missing.

After that build and install raspicam again and everything works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.