1

I'm currently trying to add the RaspiCam library found here:

https://sourceforge.net/projects/raspicam/?source=typ_redirect

To the Apriltags library found here:

http://people.csail.mit.edu/kaess/apriltags/

I unzipped the RaspiCam library and built it separately, then just copied and pasted it into the AprilTags folder. My AprilTags folder looks like this now:

AprilTags build cmake CMakeLists.txt example LICENSE Makefile pod-build raspicam-0.1.6 README.txt src systems.txt tags

Inside the raspicam-0.1.6 folder is this:

build Changelog CMakeLists.txt CMakeLists.txt.user cmake_uninstall.cmake.in dependencies README src utils

I add the library from raspicam to the top of my code in AprilTags as:

#include <raspicam/raspicam_cv.h>

and it detects it when I build. I know this because I purposefully wrote the library wrong, ex. raspicam_cvv.h, and it gave me an error because there is no library like that. So it definitely links. However, when I try to use the library in code with for example:

raspicam::RaspiCam_Cv Camera;

It gives this error:

CMakeFiles/apriltags_demo.dir/apriltags_demo.cpp.o: In function `main':
apriltags_demo.cpp:(.text.startup+0x2d4): undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
apriltags_demo.cpp:(.text.startup+0x324): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
apriltags_demo.cpp:(.text.startup+0x384): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
collect2: error: ld returned 1 exit status
example/CMakeFiles/apriltags_demo.dir/build.make:139: recipe for target 'bin/apriltags_demo' failed
make[3]: *** [bin/apriltags_demo] Error 1
CMakeFiles/Makefile2:193: recipe for target 'example/CMakeFiles/apriltags_demo.dir/all' failed
make[2]: *** [example/CMakeFiles/apriltags_demo.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make[1]: *** [all] Error 2
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2

as an undefined reference. I did some research online and found a similar query here: library is linked but reference is undefined where the solution is to change the order in which you link. However, because both projects are built using CMake, I don't know how you would change the order of linking.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
ksivakumar
  • 481
  • 2
  • 5
  • 19

1 Answers1

0

NOTE - I would make this a comment if I could, need more rep:

  • Have you tried "" over <> for your include? <> is for predefined directories while "" follows a relative path

  • This may seem like an excess check, but did you make sure you have both the .lib and corresponding .h file for the library in the same directory? Lot of people have the .lib but are missing the .h for the lib

I come across this problem when I forget to do either of these two, whether in cmake or in visual c++ through vstudio

  • Yes, I have both the .h file and .lib files in the raspberry folder. Also changing <> for "" gives same error. – ksivakumar Mar 13 '17 at 19:23