【问题标题】:Compiling Octave 4.2.1 in linux, can't link to PCRE library with GCC 4.9.3在 linux 中编译 Octave 4.2.1,无法使用 GCC 4.9.3 链接到 PCRE 库
【发布时间】:2017-03-02 19:52:47
【问题描述】:

在运行 Octave 的配置脚本时,我会这样做:

./configure CFLAGS="-I/customlibs/pcre/gnu/8.40/include -L/customlibs/pcre/gnu/8.40/lib/" LD_LIBRARY_PATH="/customlibs/pcre/gnu/8.40/lib"

我也试过了:

./configure CFLAGS="-I/customlibs/pcre/gnu/8.40/include" LDFLAGS="-L/customlibs/pcre/gnu/8.40/lib/" LD_LIBRARY_PATH="/customlibs/pcre/gnu/8.40/lib"

这两者都会产生相同的故障:

checking pcre.h usability... yes
checking pcre.h presence... no
configure: WARNING: pcre.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: pcre.h: proceeding with the compiler's result
checking for pcre.h... yes
checking pcre/pcre.h usability... no
checking pcre/pcre.h presence... no
checking for pcre/pcre.h... no
checking whether pcre.h defines the macros we need... no
configure: error: to build Octave, you must have the PCRE library and header files installed

我对它如何找到 pcre.h 感到迷茫,但无法用它做任何其他事情。我在配置线上做错了什么还是 pcre 坏了?如果它是我的配置行,我如何正确链接 pcre? 作为参考,这里是pcre路径:

ls /customlibs/pcre/gnu/8.40/
bin
include
lib
share

【问题讨论】:

  • 预期的顺序显然是 -I -L 然后 -l 在 Octave 的情况下,它被编写为期望 pcre 位于系统路径中,因此加载外部版本需要很多额外的步骤。必须使用 C_INCLUDE_PATH 和 CPLUS_INCLUDE_PATH 来强制 gcc 指向我的库。

标签: gcc compilation linker


【解决方案1】:

我也为此苦苦挣扎了一段时间,但解决方案实际上非常简单。只需对包含文件使用 CPPFLAGS 而不是 CFLAGS:

./configure CPPFLAGS="-I/customlibs/pcre/gnu/8.40/include" LDFLAGS="-L/customlibs/pcre/gnu/8.40/lib/"

配置时也不需要 LD_LIBRARY_PATH。

【讨论】:

    猜你喜欢
    • 2019-10-15
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 2013-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多