LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   libcvd configure script can't find V4L2 (http://www.linuxquestions.org/questions/linux-software-2/libcvd-configure-script-cant-find-v4l2-904698/)

RyuOni 09-23-2011 05:00 PM

libcvd configure script can't find V4L2
 
First, some information about my system:
OS: Ubuntu Linux 11.04 (specifically, lubuntu)
Code:

$ uname -a
Linux jabsys 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011 i686 i686 i386 GNU/Linux

Now onto my problem:
I am trying to build a Linux implementation of the Parallel Tracking And Mapping (PTAM) software that I obtained here for my research.

I followed the installation instructions in the PTAM README file to ensure that all dependencies are installed. I got the following versions of three dependencies to ensure compatibility, as suggested in the PTAM README file
Code:

cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/toon co -D "Mon May 11 16:29:26 BST 2009" TooN
cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" libcvd
cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" gvars3

When I try to build the PTAM software, I get the following:

Code:

$ sudo make
g++ -o PTAM main.o GLWindow2.o GLWindowMenu.o VideoSource_Linux_V4L.o System.o ATANCamera.o KeyFrame.o MapPoint.o Map.o SmallBlurryImage.o ShiTomasi.o HomographyInit.o MapMaker.o Bundle.o PatchFinder.o Relocaliser.o MiniPatch.o MapViewer.o ARDriver.o EyeGame.o Tracker.o -L MY_CUSTOM_LINK_PATH -lGVars3 -lcvd -lGL -lGLU -llapack
VideoSource_Linux_V4L.o: In function `VideoSource::VideoSource()':
VideoSource_Linux_V4L.cc:(.text+0x2b1b): undefined reference to `CVD::V4L::V4L2Client::V4L2Client(int, unsigned int, CVD::ImageRef, int, bool, int, bool)'
VideoSource_Linux_V4L.cc:(.text+0x2c29): undefined reference to `CVD::Exceptions::V4LBuffer::DeviceOpen::DeviceOpen(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.cc:(.text+0x3992): undefined reference to `CVD::Exceptions::V4LBuffer::DeviceSetup::DeviceSetup(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.o: In function `CVD::V4LBuffer<CVD::yuv422>::frame_rate()':
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE10frame_rateEv[CVD::V4LBuffer<CVD::yuv422>::frame_rate()]+0x15): undefined reference to `CVD::V4L::V4L2Client::getRate()'
VideoSource_Linux_V4L.o: In function `CVD::V4LBuffer<CVD::yuv422>::frame_pending()':
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE13frame_pendingEv[CVD::V4LBuffer<CVD::yuv422>::frame_pending()]+0x11): undefined reference to `CVD::V4L::V4L2Client::pendingFrame()'
VideoSource_Linux_V4L.o: In function `CVD::V4LBuffer<CVD::yuv422>::size()':
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE4sizeEv[CVD::V4LBuffer<CVD::yuv422>::size()]+0x1e): undefined reference to `CVD::V4L::V4L2Client::getSize()'
VideoSource_Linux_V4L.o: In function `CVD::V4LBuffer<CVD::yuv422>::put_frame(CVD::VideoFrame<CVD::yuv422>*)':
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9put_frameEPNS_10VideoFrameIS1_EE[CVD::V4LBuffer<CVD::yuv422>::put_frame(CVD::VideoFrame<CVD::yuv422>*)]+0x59): undefined reference to `CVD::V4L::V4L2Client::releaseFrame(int)'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9put_frameEPNS_10VideoFrameIS1_EE[CVD::V4LBuffer<CVD::yuv422>::put_frame(CVD::VideoFrame<CVD::yuv422>*)]+0xab): undefined reference to `CVD::Exceptions::V4LBuffer::PutFrame::PutFrame(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9put_frameEPNS_10VideoFrameIS1_EE[CVD::V4LBuffer<CVD::yuv422>::put_frame(CVD::VideoFrame<CVD::yuv422>*)]+0x131): undefined reference to `CVD::Exceptions::V4LBuffer::PutFrame::PutFrame(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9put_frameEPNS_10VideoFrameIS1_EE[CVD::V4LBuffer<CVD::yuv422>::put_frame(CVD::VideoFrame<CVD::yuv422>*)]+0x2bb): undefined reference to `CVD::Exceptions::V4LBuffer::PutFrame::PutFrame(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.o: In function `CVD::V4LBuffer<CVD::yuv422>::get_frame()':
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9get_frameEv[CVD::V4LBuffer<CVD::yuv422>::get_frame()]+0x1e): undefined reference to `CVD::V4L::V4L2Client::getFrame()'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9get_frameEv[CVD::V4LBuffer<CVD::yuv422>::get_frame()]+0x33): undefined reference to `CVD::V4L::V4L2Client::getSize()'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9get_frameEv[CVD::V4LBuffer<CVD::yuv422>::get_frame()]+0xc2): undefined reference to `CVD::Exceptions::V4LBuffer::GetFrame::GetFrame(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
VideoSource_Linux_V4L.cc:(.text._ZN3CVD9V4LBufferINS_6yuv422EE9get_frameEv[CVD::V4LBuffer<CVD::yuv422>::get_frame()]+0x1d8): undefined reference to `CVD::Exceptions::V4LBuffer::GetFrame::GetFrame(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
make: *** [PTAM] Error 1

I believe that the root of my problems is in building libcvd (one of the dependencies for PTAM). When I run the configure script for libcvd I get:

Code:

$ sudo ./configure --without-ffmpeg --without-mmx --without-v4l1buffer --with-v4l2
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for gawk... no
checking for mawk... mawk
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking for ranlib... ranlib
checking how to run the C++ preprocessor... g++ -E
checking if compiler flag -Wall works... yes
checking if compiler flag -Wextra works... yes
checking if compiler flag -pipe works... yes
checking if compiler flag -ggdb works... yes
checking if compiler flag -fPIC works... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for best optimize flags...
checking if compiler flag -O3 works... yes
checking CPU type... core2
checking if compiler flag -march=native works... yes

------------------------------------
Checking processor specific features
------------------------------------

checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking for MMXEXT support... yes
checking for SSE support... yes
checking for SSE2 support... yes
checking for SSE3 support... yes
checking for void*... yes
checking size of void*... 4
checking for inline asm statement... yes
checking assembler supports .type pseudo-op... yes

-----------------------------------------------
Checking for operating system specific features
-----------------------------------------------
checking dc1394/dc1394.h usability... yes
checking dc1394/dc1394.h presence... yes
checking for dc1394/dc1394.h... yes
checking for main in -ldc1394... yes
checking libraw1394/raw1394.h usability... yes
checking libraw1394/raw1394.h presence... yes
checking for libraw1394/raw1394.h... yes
checking libdc1394/dc1394_control.h usability... no
checking libdc1394/dc1394_control.h presence... no
checking for libdc1394/dc1394_control.h... no
checking for main in -lraw1394... yes
checking for main in -ldc1394_control... no
checking for v4l2... no
checking for strange v4l2... no
checking kernel major number... 2
checking kernel minor number... 6
checking kernel release number... 38

-------------------------------
Checking for optional libraries
-------------------------------
checking for X... libraries , headers
checking for glDrawPixels in -lGL... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for gluGetString in -lGLU... yes
checking for tr1::shared_ptr... yes
checking for TooN... yes
checking Old TooN... no
checking for dgesvd_ in -lacml... no
checking if Accelerate framework is needed for LAPACK...
checking for dgesvd_... no
checking for dgesvd_ in -llapack... yes
checking for working pthreads... yes
checking for pthread_yield... yes
checking for pthread_yield_np... no
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for png_init_io in -lpng... yes
checking jpeglib.h usability... yes
checking jpeglib.h presence... yes
checking for jpeglib.h... yes
checking for jpeg_destroy_decompress in -ljpeg... yes
checking JPEG read buffer size... 1 (safe reading)
checking tiffio.h usability... yes
checking tiffio.h presence... yes
checking for tiffio.h... yes
checking for TIFFReadRGBAImage in -ltiff... yes
checking for TIFFReadRGBAImageOriented in -ltiff... yes
checking for doxygen... no

-----------------------------------
Checking for platform compatibility
-----------------------------------
checking glob.h usability... yes
checking glob.h presence... yes
checking for glob.h... yes
checking for glob... yes
checking for GLOB_BRACE and GLOB_TILDE in glob.h... yes
checking whether feenableexcept is declared... yes
checking for posix_memalign... yes

--------------------------------
Checking for extra build options
--------------------------------


Options:
inline_asm assembler dc1394v2 dvbuffer3 videodisplay tr1_shared_ptr toon lapack pthread png jpeg tiff glob memalign

Missing options for linux-gnu:
dvbuffer ffmpeg v4l1buffer v4l2buffer v4lbuffer

Dodgy things:



SIMD support:
mmxext sse sse2 sse3

Missing SIMD support for i686-pc-linux-gnu:
mmx

-g -Wall -Wextra -pipe -ggdb -fPIC -msse -msse -msse2 -msse3 -pthread
-ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394 -L -lX11 -lXext -pthread
Generating config... configuration unchanged
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING:  Makefile.in seems to ignore the --datarootdir setting

Specifically, the two lines
Code:

checking for v4l2... no
checking for strange v4l2... no

concern me because I know that video4linux2 is installed.

I ran pkg-config for v4l2 and got the output:
Code:

$ pkg-config --libs /usr/lib/pkgconfig/libv4l2.pc
-lv4l2

So after running the configuration script for libcvd, I modified a couple of lines in the libcvd Makefile to add -lv4l2 to the build process like so
Code:

LOADLIBES = -ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394 -lv4l2  -L -lX11 -lXext -pthread
Unfortunately, after re-building and re-installing libcvd and attempting to re-build PTAM, I am still getting the same errors as before.

I'm kind of assuming the main problem is that V4L2 isn't getting built into/utilized by libcvd. How can make the libcvd configuration script aware of V4L2?


Any help on this would be greatly appreciated!


Thanks,
Jake

corp769 09-23-2011 07:24 PM

Hello,

I have found the following site for you, as it seems you are missing dependencies. One a side note, it almost sounds like you have v4l2 installed, but not the development files for v4l2. I would check the dependencies and install as needed - http://www.minus-reality.com/how-to-...n-ubuntu-9-10/

Cheers,

Josh

RyuOni 09-23-2011 10:20 PM

Thanks for the reply Josh!

I did take a look at http://www.minus-reality.com/how-to-...n-ubuntu-9-10/ and I installed any of dependencies that were not already installed on my system. However, I was still facing the same issue: libcvd did not recognize that V4L2 is installed.

Fortunately, I was able to figure it out!
I looked at the config.log file and found the following segment.
Code:

configure:6970: checking for v4l2
configure:6984: g++ -c -g  -Wall -Wextra -pipe -ggdb -fPIC -msse -msse -msse2 -msse3  -INONE/include conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:4:20: error: 'V4L2_PIX_FMT_GREY' was not declared in this scope
configure:6990: $? = 1
configure: failed program was:
|      #include <sys/types.h>
|                                                              #include <linux/types.h>
|                                                              #include <linux/videodev.h>
|                                                              int main(){V4L2_PIX_FMT_GREY;return 0;}
configure:7001: result: no

'V4L2_PIX_FMT_GREY' is defined in videodev2.h - the V4L2 version of videodev.h - so first, I added
Code:

#include <linux/videodev2.h>
to the test code shown in the above config.log to line 6976 in the libcvd configure script.

That did cause libcvd configure to [FINALLY] recognize that V4L2 is installed on my system and create the libcvd Makefile such that it attempts to build the necessary V4L2 components into libcvd.so.0.7.
Then, I realized that in order for libcvd to build properly, anywhere in the libcvd source that videodev.h is included, videodev2.h also needs to be included (yes, it needs both and I couldn't just replace videodev.h with videodev2.h), so I [temporarily] included videodev2.h within videodev.h. That worked! From that point, libcvd built and installed properly with V4L2 and I was able to build and test PTAM! :D

Then, I remembered that earlier (days ago in fact), I had actually created '/usr/include/linux/videodev.h' as a symbolic link to '/usr/include/libv4l1-videodev.h' because libcvd source files try to include '/usr/include/linux/videodev.h', but it doesn't exist by default on Ubuntu 11.04. At this point I kicked myself because in hind sight, I SHOULD HAVE just created a dummy videodev.h file in /usr/include/linux/ and included '/usr/include/libv4l1-videodev.h' and '/usr/include/linux/videodev2.h' within that for the purposes of installing libcvd and PTAM... *sigh*

Oh well. At least it works now!

corp769 09-23-2011 11:28 PM

Oh cool, you definitely beat me to it then. Glad to hear you got it all sorted out man!


All times are GMT -5. The time now is 11:50 AM.