1

I'm having problems trying to install OpenCV 2.0 on Ubuntu 14.04. When I want to install the dependencies I got the following problem:

andres@andres-VirtualBox:~$ sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
[sudo] password for andres:
Reading package lists...
Done Building dependency tree  Reading state information...
Done Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created or been
moved out of Incoming. The following information may help to resolve the
situation:

The following packages have unmet dependencies:
libtiff4-dev : Depends: libtiff5-dev (> 4.0.3-6~) but it is not going to be installed 
E: Unable to correct problems, you have held broken packages.

I want to install OpenCV 2.0 because there is an old project that uses that version of OpenCV.

Update 1

1: I installed libtiff5-dev but then it threw another error:

The following packages have unmet dependencies:
 libjpeg-turbo8-dev : Conflicts: libjpeg62-dev but 6b1-4ubuntu1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Then I removed libjpeg-turbo8-dev but it uninstalled libtiff5-dev. Someone posted about the problem like 4 years ago without a solution:

http://ubuntuforums.org/showthread.php?t=1985957

Update 2

I used aptitude instead of apt-get to install the dependencies. Everything went ok but I checked that I have ffmpeg and v4l as no. I didn't care and I tried to compile the library. I got the following compilation errors:

In file included from ../include/opencv/cxcore.h:2123:0,
                 from cxcore/_cxcore.h:60,
                 from cxcore/cxprecomp.cpp:43:
../include/opencv/cxcore.hpp:169:13: error: ‘ptrdiff_t’ does not name a type
     typedef ptrdiff_t difference_type;
             ^
In file included from ../include/opencv/cxcore.hpp:2243:0,
                 from ../include/opencv/cxcore.h:2123,
                 from cxcore/_cxcore.h:60,
                 from cxcore/cxprecomp.cpp:43:
../include/opencv/cxoperations.hpp:1916:15: error: ‘ptrdiff_t’ does not name a type
 static inline ptrdiff_t operator - (const FileNodeIterator& it1, const FileNodeIterator& it2)
               ^
../include/opencv/cxoperations.hpp:2465:31: error: ‘ptrdiff_t’ does not name a type
 template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a,
                               ^
In file included from ../include/opencv/cxcore.hpp:2244:0,
                 from ../include/opencv/cxcore.h:2123,
                 from cxcore/_cxcore.h:60,
                 from cxcore/cxprecomp.cpp:43:
../include/opencv/cxmat.hpp: In member function ‘void cv::Mat::locateROI(cv::Size&, cv::Point&) const’:
../include/opencv/cxmat.hpp:356:5: error: ‘ptrdiff_t’ was not declared in this scope
     ptrdiff_t delta1 = data - datastart, delta2 = dataend - datastart;
     ^
../include/opencv/cxmat.hpp:356:5: note: suggested alternatives:
In file included from /usr/include/c++/4.8/utility:68:0,
                 from /usr/include/c++/4.8/algorithm:60,
                 from ../include/opencv/cxcore.hpp:51,
                 from ../include/opencv/cxcore.h:2123,
                 from cxcore/_cxcore.h:60,
                 from cxcore/cxprecomp.cpp:43:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:187:28: note:   ‘std::ptrdiff_t’
   typedef __PTRDIFF_TYPE__ ptrdiff_t;
                            ^
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:187:28: note:   ‘std::ptrdiff_t’
In file included from ../include/opencv/cxcore.hpp:2244:0,
                 from ../include/opencv/cxcore.h:2123,
                 from cxcore/_cxcore.h:60,
                 from cxcore/cxprecomp.cpp:43:
../include/opencv/cxmat.hpp:356:15: error: expected ‘;’ before ‘delta1’
     ptrdiff_t delta1 = data - datastart, delta2 = dataend - datastart;
               ^
../include/opencv/cxmat.hpp:358:9: error: ‘delta1’ was not declared in this scope
     if( delta1 == 0 )
         ^
../include/opencv/cxmat.hpp:367:31: error: ‘delta2’ was not declared in this scope
     wholeSize.height = (int)((delta2 - minstep)/step + 1);
                               ^
make[2]: *** [cxprecomp.lo] Error 1
make[2]: Leaving directory `/home/andres/OpenCV-2.0.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/andres/OpenCV-2.0.0'
make: *** [all] Error 2
6
  • 1
    Did you run sudo apt-get update first? Both libtiff4-dev (4.0.3-7ubuntu0.3) and libtiff5-dev (4.0.3-7ubuntu0.3) are happily installed on my 14.04 system Feb 15, 2016 at 1:42
  • Yes, I updated my question with more problems that I'm facing.
    – andrestoga
    Feb 15, 2016 at 2:14
  • OpenCV-2.0.0 appears to configure OK for me with libjpeg-turbo8-dev but without libjpeg62-dev: I suggest you try removing that package from the prerequisite list and seeing if you can configure the build anyhow Feb 15, 2016 at 2:32
  • I did it and I get the compilation errors that I inserted at the end of my original question.
    – andrestoga
    Feb 16, 2016 at 1:52
  • 2
    Try editing the package's include/opencv/cxcore.hpp file and adding #include <cstddef> to its list of standard headers: see here code.opencv.org/issues/1028 Feb 16, 2016 at 2:18

1 Answer 1

0

I've tested this on fresh installed Ubuntu 12.04 and 14.04, and both give almost the same error. Error regarding ibjpeg-turbo8-dev : Conflicts: libjpeg62-dev.

If you are using virtual machine and you are not afraid to damage it you could try run this command. Accept everything that aptitute will suggest and proceed with result.

sudo aptitude install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev

Update

After installation via aptitude OP get the compilation problem. This problem is solved by @steeldriver suggestion in comments:

Try editing the package's include/opencv/cxcore.hpp file and adding #include <cstddef> to its list of standard headers: see here http://code.opencv.org/issues/1028

5
  • I followed your instructions but I don't know if it worked or not because when I configured the compilation it reported ffmpeg and v4l as no. How I can get ffmpeg and v4l as yes?
    – andrestoga
    Feb 16, 2016 at 1:30
  • I got compilation errors. I updated my question.
    – andrestoga
    Feb 16, 2016 at 1:45
  • @user702475 user steeldriver gave you nice solution in the comments. Did you tried it? Do you have some troubles with this?
    – c0rp
    Feb 16, 2016 at 12:47
  • 1
    Yes, I tried it. After that, everything worked well. Thanks for your help.
    – andrestoga
    Feb 18, 2016 at 22:12
  • @andrestoga, thanks for response. I will update answer, don't forget about other guys with the same problem.
    – c0rp
    Feb 19, 2016 at 10:16

Not the answer you're looking for? Browse other questions tagged .