在linux中编译Octave 4.2.1,无法通过GCC 4.9.3链接到PCRE库

时间:2017-03-02 19:52:48

标签: gcc compilation linker

运行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

1 个答案:

答案 0 :(得分:0)

我一直在努力解决这个问题,但解决方案实际上非常简单。只需使用CPPFLAGS而不是CFLAGS来包含文件:

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

配置时也不需要LD_LIBRARY_PATH。