GraphicsMagick 的 OpenCL 开发记录(一)

本文讲述了在ImageMagick配置过程中遇到的关于添加OpenCL支持的问题,涉及修改configure.ac、ax_have_opencl.m4以及解决AC_MSG_RESULT和AX_CHECK_FRAMEWORK冲突的过程,最终通过替换ax_check_framework.m4解决了问题并提供了编译建议。
摘要由CSDN通过智能技术生成

<2022-02-24 Thu>

configure增加--enable-opencl参数

拷贝ImageMagick中的m4/ax_have_opencl.m4,在configure.ac中添加:

# Enable support for OpenCL
no_cl=yes
AX_HAVE_OPENCL([C])
if test "X$no_cl" != 'Xyes'; then
  MAGICK_FEATURES="OpenCL $MAGICK_FEATURES"
fi

在根目录下运行autoreconf -vif重新生成configure,但出现错误:

$ autoreconf -vif
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'config'.
libtoolize: copying file 'config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
configure.ac:1057: error: possibly undefined macro: AC_MSG_RESULT
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

试了比如安装pkg-configautoconf-archive都不能解决,开发环境archlinuxautoconf的版本是2.71,换到了ubuntu2.69的环境下也不行。

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
$ autoconf --version
autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

可以将ax_have_opencl.m4的所有AC_MSG_RESULT全部删除(注:注释掉AC_MSG_RESULT的话还会出现其它错误导致不能生成configure),虽然能成功生成configure,但是运行./configure时会出现如下错误:

$ ./configure
...
...
checking for gcc option to support OpenMP... -fopenmp
./configure: line 7812: syntax error near unexpected token `OpenCL,'
./configure: line 7812: `        AX_CHECK_FRAMEWORK(OpenCL,'

临时解决的方法是将configure中的AX_CHECK_FRAMEWORK(...)的代码段删除。

AX_CHECK_FRAMEWORK的答案来自:

$ grep -rn 'AX_CHECK_FRAMEWORK'
ImageMagick/m4/ax_check_framework.m4:6:dnl @synopsis AX_CHECK_FRAMEWORK(framework, [action-if-found], [action-if-not-found])
ImageMagick/m4/ax_check_framework.m4:15:AC_DEFUN([AX_CHECK_FRAMEWORK],[
ImageMagick/m4/ax_have_opencl.m4:94:        AX_CHECK_FRAMEWORK([OpenCL], [

即,将ImageMagickm4/ax_check_framework.m4拷贝过来即可,惊奇的是AX_CHECK_FRAMEWORK的问题解决,之前AC_MSG_RESULT的问题同时也迎刃而解。

可以删除configure文件后再运行autoreconf来代替autoreconf -vif,这样生成的configure可以最大限度的与原configure保持一致。

commitsupport ‘–enable-opencl’

  • 22
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值