【问题标题】:configure script not enabling make to generate shared library配置脚本不允许 make 生成共享库
【发布时间】:2013-01-16 03:35:50
【问题描述】:

这是关于编译 libjpeg v6b(如果相关)。

我运行 ./configure --prefix=/c/tmp/jpeg-6b-build --enable-shared --enable-static 就像安装文档说的那样,但 libtool 没有它。

checking dynamic linker characteristics... no
checking if libtool supports shared libraries... no
checking whether to build shared libraries... no
checking whether to build static libraries... yes

我想我需要这个共享库来编译一些函数。 libjpeg 本身编译得很好,它生成的 .exe 可以工作,但我需要将源代码用于其他用途。由于某种原因,v6b 不会生成 .DLL,而 v9 会生成。

./configure 命令的完整输出:

ild
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking how to run the C preprocessor... gcc -E
checking for function prototypes... yes
checking for stddef.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for size_t... yes
checking for type unsigned char... yes
checking for type unsigned short... yes
checking for type void... yes
checking for working const... yes
checking for inline... __inline__
checking for broken incomplete types... ok
checking for short external names... ok
checking to see if char is signed... yes
checking to see if right shift is signed... yes
checking to see if fopen accepts b spec... yes
checking for a BSD compatible install... /bin/install -c
checking for ranlib... ranlib
checking host system type... i386-pc-mingw32
checking for ranlib... ranlib
checking for gcc... gcc
checking whether we are using GNU C... yes
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... no
checking if gcc static flag -static works... -static
checking whether ln -s works... no
checking for ld used by GCC... ./c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../
../mingw32/bin/ld.exe
checking if the linker (./c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../ming
w32/bin/ld.exe) is GNU ld... yes
checking whether the linker (./c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../..
/mingw32/bin/ld.exe) supports shared libraries... yes
checking for BSD-compatible nm... /mingw/bin/nm
checking command to parse /mingw/bin/nm output... no
checking how to hardcode library paths into programs... immediate
checking for ./c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.
exe option to reload object files... -r
checking dynamic linker characteristics... no
checking if libtool supports shared libraries... no
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for objdir... .libs
creating libtool
checking libjpeg version number... 62
creating ./config.status
creating Makefile
creating jconfig.h
jconfig.h is unchanged

相关问题:Need help compiling jpegtran.c code from libjpeg

【问题讨论】:

    标签: dll linker shared-libraries static-libraries libjpeg


    【解决方案1】:

    我遇到了同样的问题,我相信这是因为 jpeg-6b 是使用非常旧版本的 autotools 构建的(如果 sourceforge 页面正确,jpeg-6b 版本可以追溯到 1998 年)。

    问题在于它检查 gcc 是否支持 -fPIC 标志的方式:

    检查 gcc 选项以生成 PIC... -fPIC
    检查 gcc PIC 标志 -fPIC 是否有效...否

    这就是他们从 config.log 执行检查的方式:

    ltconfig:547: 检查 gcc PIC 标志 -fPIC 是否有效
    ltconfig:548: gcc -c -fPIC -DPIC -I/local/include conftest.c 1>&5
    conftest.c:1:0:警告:-fPIC 忽略目标(所有代码都与位置无关)
    
     ^

    注意 gcc 如何返回警告,它可能返回退出代码 1 导致检查失败。并且位置无关的代码对于共享库来说是必要的,所以这使它认为它无法制作它们,并且它稍后会输出:

    正在检查是否构建共享库...否

    将其与 libjpeg9 进行比较,我假设它使用了更新版本的 autotools:

    检查 gcc -std=gnu99 选项以生成 PIC... -DDLL_EXPORT -DPIC
    检查 gcc -std=gnu99 PIC flag -DDLL_EXPORT -DPIC 是否有效...是的

    并且来自 config.log:

    configure:10108: 检查 gcc -std=gnu99 选项以生成 PIC
    配置:10115:结果:-DDLL_EXPORT -DPIC
    配置:10123:检查 gcc -std=gnu99 PIC 标志 -DDLL_EXPORT -DPIC 是否有效
    配置:10141:gcc -std=gnu99 -c -g -O2 -I/local/include -DDLL_EXPORT -DPIC -DPIC conftest.c >&5
    配置:10145:$? = 0
    配置:10158:结果:是

    我最终编译了 libjpeg9,但我认为如果您可以使用更新版本的自动工具重新创建 ./configure 脚本,libjpeg6 也可能是可编译的。

    【讨论】:

      【解决方案2】:

      你应该尝试运行

      ./configure --help
      

      并查看所有可用的配置标志,也许你拼错了一些,或者你需要--enable-dynamic 或不同的东西。

      对于配置输出,您还可以参考 config.log,它位于项目(在您的情况下是 libjpeg 的)目录中,就在 configure 文件旁边。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-11
        • 1970-01-01
        • 1970-01-01
        • 2014-10-10
        • 1970-01-01
        相关资源
        最近更新 更多