GNU Octave 编译失败,并显示 libinterp/.libs/liboctinterp.so: undefined reference to `Magick::*

GNU Octave 编译失败,并显示 libinterp/.libs/liboctinterp.so: undefined reference to `Magick::*

语境

我的uname -rv4.4.0-64-generic #85~14.04.1-Ubuntu SMP Mon Feb 20 12:10:54 UTC 2017--- 我的编译器是 GNU gcc 6.3.0 --- 我正在从源代码编译 GNU Octave。我一直在尝试编译 Octave 版本 4.0.2、4.2.0 和 4.2.1

我使用调用配置构建

${srcdir}/configure \
--prefix=/opt/octave/4.2.1 \
--with-java-homedir=/usr/lib/jvm/default-java \
--with-java-libdir=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server 

问题

在所有情况下,make 阶段都会失败并出现以下错误

libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::attribute(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::CoderInfo::description[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::comment[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::magick[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::CoderInfo::CoderInfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

证据

在准备手动安装时,我运行了sudo apt-get build-dep octave.这与 Ubuntu 14.04 当前支持的版本 3.8.1 相关。然而,我认为这不会有什么坏处。 (来自源目录中的 INSTALL.OCTAVE 文件的建议)

为了安全起见,我从 Ubuntu 存储库 8:6.7.7.10-6ubuntu3.4安装了库libmagickcore-dev, 。无论有没有它们,问题都会出现。libmagickwand-devlibmagick++-dev

因此,dpkg -l | grep magick显示

ii imagemagick 8:6.7.7.10-6ubuntu3.4 amd64 image manipulation programs
ii imagemagick-common 8:6.7.7.10-6ubuntu3.4 all image manipulation programs -- infrastructure
ii libgraphicsmagick++1-dev 1.3.18-1ubuntu3 amd64 format-independent image processing - C++ development files
ii libgraphicsmagick++3 1.3.18-1ubuntu3 amd64 format-independent image processing - C++ shared library
ii libgraphicsmagick1-dev 1.3.18-1ubuntu3 amd64 format-independent image processing - C development files
ii libgraphicsmagick3 1.3.18-1ubuntu3 amd64 format-independent image processing - C shared library
ii libmagick++-dev 8:6.7.7.10-6ubuntu3.4 amd64 object-oriented C++ interface to ImageMagick - development files
ii libmagick++5:amd64 8:6.7.7.10-6ubuntu3.4 amd64 object-oriented C++ interface to ImageMagick
ii libmagickcore-dev 8:6.7.7.10-6ubuntu3.4 amd64 low-level image manipulation library - development files
ii libmagickcore5:amd64 8:6.7.7.10-6ubuntu3.4 amd64 low-level image manipulation library
ii libmagickcore5-extra:amd64 8:6.7.7.10-6ubuntu3.4 amd64 low-level image manipulation library - extra codecs
ii libmagickwand-dev 8:6.7.7.10-6ubuntu3.4 amd64 image manipulation library - development files
ii libmagickwand5:amd64 8:6.7.7.10-6ubuntu3.4 amd64 image manipulation library

配置阶段顺利退出,状态为 0。

(注意配置阶段并不是100%万无一失:之前的一次构建尝试失败了,因为我没有gnulib安装,配置没有捕获)

https://stackoverflow.com/questions/39228019/error-while-compiling-octave-with-gcc表示liboctinterp.so从 Octave 4.0.2 开始,未定义的引用是 的一个已知特征。要么这种错误行为在 4.2.0 中持续存在,要么存在我遗漏的隐藏要求。

问题

我应该怎样做才能成功完成Octave的编译?

答案1

这里有同样的错误,但上面有关于冲突库的警告,这是有用的线索。

/usr/local/gcc-6.4.0_binutils-2.28.1_isl/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libjpeg.so.8, needed by /usr/lib/../lib64/libtiff.so, may conflict with libjpeg.so.62
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::attribute(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::CoderInfo::description[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::comment[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::Image::magick[abi:cxx11]() const'
libinterp/.libs/liboctinterp.so: undefined reference to `Magick::CoderInfo::CoderInfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

Magick::Image::ping预计会在 c++ 库中,让我们检查一下使用了哪一个:

ldd libinterp/.libs/liboctinterp.so | grep -i magick++
        libGraphicsMagick++.so.12 => /usr/local/gcc-6.4.0_binutils-2.28.1_isl/lib64/libGraphicsMagick++.so.12 (0x00007faa870ab000)

Magick::Image::ping确实存在:

nm -C /usr/local/gcc-6.4.0_binutils-2.28.1_isl/lib64/libGraphicsMagick++.so | grep ping
000000000004c7a0 T Magick::Image::ping(Magick::Blob const&)
000000000004c740 T Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

因此,某些东西阻止了链接器正确使用它。

libGraphicsMagick++.so 很好的另一个线索:具有相同的建造程序,相同的库,八度稳定分支构建良好,而开发分支失败。

让我们认真对待之前的警告。其实是已经注意到

请注意,在 openSUSE 12.04 和 13.02 中,libjpeg-devel 软件包会导致安装 libjpeg62.so,这可能与同时安装的 libjpeg8.so 发生冲突。这就是为什么我们建议不要安装 libjpeg-devel,而是安装 libjpeg8-devel。

libjpeg62-devel必须被取代,因为有几个包依赖于jpeglibjpeg8-devel库。

以下命令是在 openSUSE 42.2 上发出的。

sudo zypper install libjpeg8-devel

Problem: libjpeg62-devel-62.2.0-35.3.1.x86_64 conflicts with namespace:otherproviders(libjpeg-devel) provided by libjpeg8-devel-8.1.2-119.5.x86_64
Solution 1: deinstallation of libjpeg62-devel-62.2.0-35.3.1.x86_64
Solution 2: do not install libjpeg8-devel-8.1.2-119.5.x86_64

Choose from above solutions by number or cancel [1/2/c] (c): 1

The following NEW package is going to be installed:
libjpeg8-devel

The following package is going to be REMOVED:
libjpeg62-devel

1 new package to install, 1 to remove.
Overall download size: 110.8 KiB. Already cached: 0 B. After the operation, additional 63.6 KiB will be used.
Continue? [y/n/...? shows all options] (y):

但 jpeg 库仍然存在。让我们找到这个包:

zypper se -f /usr/lib64/libjpeg.so.62.2.0
+ | libjpeg62 | The MMX/SSE accelerated JPEG compression/decompression library | package

删除库:

sudo zypper rm libjpeg62
The following package is going to be REMOVED:
libjpeg62

然后重建GraphicsMagick-1.3.28,安装。八度音阶构建现已通过。

答案2

我遇到了同样的问题(在 RHEL7 上),并且偶然发现了这个问题,所以我想我应该分享一下为我解决这个问题的方法。

运行lddlibinterp/.libs/liboctinterp.so表明没有依赖于libGraphicsMagick++.so。我检查了 config.log,发现 configure 只会查找头文件,而不会检查库。运行后configure --help发现有一个--with-magick=LIB选项。所以我添加了--with-magick=/path/to/libGraphicsMagick++.so,然后它就建立了。

相关内容