使用opencv自带的staticlib库时出现了一个问题:
opencv_highgui243d.lib(grfmt_exr.obj) : error LNK2019: 无法解析的外部符号 "public: __thiscall Imf::Chromaticities::Chromaticities(class Imath::Vec2<float> const &,class Imath::Vec2<float> const &,class Imath::Vec2<float> const &,class Imath::Vec2<float> const &)" (??0Chromaticities@Imf@@QAE@ABV?$Vec2@M@Imath@@000@Z),该符号在函数 "public: __thiscall cv::ExrDecoder::ExrDecoder(void)" (??0ExrDecoder@cv@@QAE@XZ) 中被引用
找了很多帖子都没有解决。经过搜索在opencv下发现了grfmt_exr.cpp文件,打开后看到里面包含了下面几个头文件:
#include <ImfHeader.h>
#include <ImfInputFile.h>
#include <ImfOutputFile.h>
#include <ImfChannelList.h>
#include <ImfStandardAttributes.h>
再去staticlib库里面找,看到IlmImfd.lib,是不是长得很像,添加到附加依赖项,搞定。
想了一下发现,开始按照其他作者文章配置的时候是2.31版本的,可能里面没有IlmImfd.lib,是后面版本新加的。把staticlib里面所有的lib都添加进来就可以了。这个问题浪费了不少时间,还是缺少经验啊。