当前位置: 首页 > 工具软件 > Tclip > 使用案例 >

php扩展 tclip,CentOS6下编译php-tclip扩展报错

王彭薄
2023-12-01

系统信息: 2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

PHP版本:5.4.25

OpenCV版本:OpenCV-2.4.10.4

gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)

报错信息:

configure: error: no result from pkg-config opencv --libs --cflags opencv

错误信息在在百度上google一下,发现了2个比较有用的结果:

跟我的错误一样,不过他们是MAC下的,跟我的情况还不一样,根据两篇文章中的内容找了下:

执行 pkg-config opencv --libs --cflags opencv 返回结果:

-I/usr/local/include/opencv -I/usr/local/include /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl

因为源码中对该结果进行循环判断,方便阅读格式化一下,即:

-I/usr/local/include/opencv

-I/usr/local/include

/usr/local/lib/libopencv_calib3d.so

/usr/local/lib/libopencv_contrib.so

/usr/local/lib/libopencv_core.so

/usr/local/lib/libopencv_features2d.so

/usr/local/lib/libopencv_flann.so

/usr/local/lib/libopencv_gpu.so

/usr/local/lib/libopencv_highgui.so

/usr/local/lib/libopencv_imgproc.so

/usr/local/lib/libopencv_legacy.so

/usr/local/lib/libopencv_ml.so

/usr/local/lib/libopencv_nonfree.so

/usr/local/lib/libopencv_objdetect.so

/usr/local/lib/libopencv_ocl.so

/usr/local/lib/libopencv_photo.so

/usr/local/lib/libopencv_stitching.so

/usr/local/lib/libopencv_superres.so

/usr/local/lib/libopencv_ts.a

/usr/local/lib/libopencv_video.so

/usr/local/lib/libopencv_videostab.so

-lrt

-lpthread

-lm

-ldl

判断得出该错误的关键代码 tclip-1.0.0/php_ext/config.m4:

OPENCV_FLAGS="`pkg-config opencv --libs --cflags opencv "

opencv_lib_path=""

for i in $OPENCV_FLAGS;do

if test ${i:0:2} = "-I" ;then

PHP_ADD_INCLUDE(${i:2})

elif test ${i:0:2} = "-L" ;then

opencv_lib_path=${i:2}

elif test ${i:${#i}-3} = ".so" ;then

dir_name=`dirname $i`

file_name=${i/$dir_name/}

file_name=${file_name/\/lib/}

file_name=${file_name/.so/}

#PHP_ADD_LIBRARY_WITH_PATH($file_name,$dir_name,TCLIP_SHARED_LIBADD)

PHP_ADD_LIBRARY_WITH_PATH($file_name,$dir_name,TCLIP_SHARED_LIBADD)

elif test ${i:${#i}-6} = ".dylib" ;then

dir_name=`dirname $i`

file_name=${i/$dir_name/}

file_name=${file_name/\/lib/}

file_name=${file_name/.dylib/}

PHP_ADD_LIBRARY_WITH_PATH($file_name,$dir_name,TCLIP_SHARED_LIBADD)

elif test ${i:0:2} = "-l" ;then

file_name=${i:2}

PHP_ADD_LIBRARY_WITH_PATH($file_name,$opencv_lib_path,TCLIP_SHARED_LIBADD)

else

AC_MSG_ERROR([no result from pkg-config opencv --libs --cflags opencv])

fi

done

很明显是/usr/local/lib/libopencv_ts.a导致了该错误,实在太菜了,不懂C语言,也不晓得这个是做什么用的,就参考以上2篇文章

OPENCV_FLAGS="`pkg-config opencv --libs --cflags opencv` "

中pkg-config opencv --libs --cflags opencv修改为该命令执行结果,并移除/usr/local/lib/libopencv_ts.a 编译就通过了

来反馈下,海龙大神抽空看下是什么问题导致的。

 类似资料: