问题描述
我在Visual Studio 2019(带有平台工具集v142)上将OpenCV编译为静态库,然后编写了一个链接opencv库的演示程序,一切正常。但是,当我在Visual Studio 2015(带有平台工具集v140)上编译演示时,它抱怨链接错误:
1>------ Build started: Project: parvati_demo,Configuration: Release Win32 ------
1>opencv_imgproc342.lib(resize.obj) : error LNK2019: unresolved external symbol ___libm_sse2_sincos_ referenced in function "void __cdecl cv::interpolateLanczos4(float,float *)" (?interpolateLanczos4@cv@@YAXMPAM@Z)
1>E:\CPPCode\projects\parvati_release1\build32\Release\parvati_demo.exe : fatal error LNK1120: 1 unresolved externals
2>------ Skipped Build: Project: ALL_BUILD,Configuration: Release Win32 ------
2>Project not selected to build for this solution configuration
========== Build: 0 succeeded,1 failed,1 up-to-date,1 skipped ==========
根据此page;在Visual Studio 2015/17/19中确保二进制兼容性:
我发现函数cv::interpolateLanczos4
被定义为
static inline void interpolateLanczos4( float x,float* coeffs )
{
static const double s45 = 0.70710678118654752440084436210485;
static const double cs[][2]=
{{1,0},{-s45,-s45},{0,1},{s45,{-1,s45},-1},s45}};
if( x < FLT_EPSILON )
{
for( int i = 0; i < 8; i++ )
coeffs[i] = 0;
coeffs[3] = 1;
return;
}
float sum = 0;
double y0=-(x+3)*CV_PI*0.25,s0 = std::sin(y0),c0= std::cos(y0);
for(int i = 0; i < 8; i++ )
{
double y = -(x+3-i)*CV_PI*0.25;
coeffs[i] = (float)((cs[i][0]*s0 + cs[i][1]*c0)/(y*y));
sum += coeffs[i];
}
sum = 1.f/sum;
for(int i = 0; i < 8; i++ )
coeffs[i] *= sum;
}
其中使用了std::sin()
中声明的std::cos()
和corecrt_math.h
。因此,我猜错了的符号与libm
或xxxcrt.lib
有关。最终,我在Windows 10 SDk中找到了ucrt.lib
,但是它也不起作用。谁可以帮助我?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)