一个比较诡异的编译错误
In file included from /Users/gerrie/source/offical/opencv-2.4.11/3rdparty/openexr/IlmImf/ImfPreviewImage.cpp:43:
/Users/gerrie/source/offical/opencv-2.4.11/3rdparty/openexr/IlmImf/ImfCheckedArithmetic.h:66:5: error: implicit instantiation of undefined template
‘Imf::StaticAssertionFailed’
IMF_STATIC_ASSERT (!std::numeric_limits::is_signed &&
^
google不到相同的错误.看了下源码里是这样的:
/Users/gerrie/source/offical/opencv-2.4.11/modules/highgui/src/cap_ffmpeg_impl.hpp
template <bool b> struct StaticAssertionFailed{};
template <> struct StaticAssertionFailed <true>;
//template <> struct StaticAssertionFailed <true> {};
#define IMF_STATIC_ASSERT(x) \
do {StaticAssertionFailed <x> staticAssertionFailed;} while (false)
原因是第二行编译器没有识别模板定义,osx编译器和linux有差异.
template <> struct StaticAssertionFailed {}
这样改就可以了.
——————-issue 2———————————
issue:
error: “libswscale is necessary to build the newer OpenCV ffmpeg wrapper”
解决:
brew info ffmpeg 查看安装信息
其实我是安装过的.
在 /usr/local/lib 可以找到相关库.
所以
/Volumes/more/source/offical/opencv-2.4.11/modules/highgui/src/cap_ffmpeg_impl.hpp
//@wei #ifdef WIN32
#define HAVE_FFMPEG_SWSCALE 1
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#else
修改为
//@wei #ifdef WIN32
#if 1
#define HAVE_FFMPEG_SWSCALE 1
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#else