【问题标题】:Cross-compile a gnulib based project to MinGW将基于 gnulib 的项目交叉编译到 MinGW
【发布时间】:2016-11-29 16:32:09
【问题描述】:

我正在尝试将这个 project 交叉编译到 MinGW。

该项目使用 autotools 作为构建系统,并依赖于libcurlCUnitJansson 和一些 gnulib 模块。

我已经为x86_64-w64-mingw32 编译并安装在/home/user/mingw64 下的所有依赖项

我跑:

$ gnulib-tool --update
$ autoreconf -fi
$ CURL_CFLAGS="-I/home/user/mingw64/usr/local/include" \
CURL_LIBS="-L/home/user/mingw64/usr/local/lib -lcurl" \
JANSSON_CFLAGS="-I/home/user/mingw64/usr/local/include" \
JANSSON_LIBS="-L/home/user/mingw64/usr/local/lib -ljansson" \
CUNIT_CFLAGS="-I/home/user/mingw64/usr/local/include" \
CUNIT_LIBS="-L/home/user/mingw64/usr/local/lib -lcunit" \
./configure --host=x86_64-w64-mingw32
$ make

我得到这个错误:

make  all-recursive
make[1]: Entering directory '/home/user/projects/shill'
Making all in po
make[2]: Entering directory '/home/user/projects/shill/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/user/projects/shill/po'
Making all in lib
make[2]: Entering directory '/home/user/projects/shill/lib'
make[2]: *** No rule to make target 'lib/errno.h', needed by 'all'.  Stop.
make[2]: Leaving directory '/home/user/projects/shill/lib'
Makefile:1897: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/user/projects/shill'
Makefile:1429: recipe for target 'all' failed
make: *** [all] Error 2

errno.h 是 gnulib 模块的一部分。所以我认为问题出在Makefile.am中的这一部分:

# Find gnulib headers.
ACLOCAL_AMFLAGS = -I m4

AM_CPPFLAGS = \
  -DLOCALEDIR='"$(localedir)"' \
  -Ilib -I$(top_srcdir)/lib \
  -Isrc -I$(top_srcdir)/src \

但我想不出解决方案。我完全按照gnulib manual 中描述的说明进行操作。

【问题讨论】:

  • 在某些 Makefile 中有一行像 all: ... lib/errno.h ... (或在变量替换后扩展为该行)是您的问题的直接原因。
  • @RossRidge 所有Makefiles 都是由自动工具自动生成的,所以即使我能找到错误并修复它,它也不起作用。 Makefiles 将重新生成并覆盖修复。
  • 所以通过修改源来修复它。
  • 那是我做不到的,你能帮忙吗?会很好:D
  • gnulib 构建了吗? (你在某处有 libgnu.a 吗?在某处有 errno.h?是 -> 包含路径问题。否 -> 构建依赖问题。

标签: c cross-compiling autotools gnulib


【解决方案1】:

我设法找到了解决此问题的方法。显然autotools 并不像我想象的那么容易。

  1. 我不得不重新生成 gnulib 模块,这次指定 --makefile-name 参数。即。

    $ gnulib-tool ... --makefile-name=gnulib.mk ...
    
  2. 我从configure.ac 中的自动生成文件中删除了lib/Makefile。所以而不是:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
           po/Makefile.in
           lib/Makefile])
    

    现在我有:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
               po/Makefile.in])
    
  3. 我在Makefile.am 中从SUBDIRS 中删除了lib。 IE。而不是:

    # Subdirectories to descend into.
    SUBDIRS = po lib
    

    我有:

    # Subdirectories to descend into.
    SUBDIRS = po
    
  4. 我在lib 目录中创建了一个名为local.mk 的新文件,内容如下:

    include lib/gnulib.mk
    
    # Allow "make distdir" to succeed before "make all" has run.
    dist-hook: $(noinst_LIBRARIES)
    .PHONY: dist-hook
    
  5. 并将其包含在Makefile.am

    include $(top_srcdir)/lib/local.mk
    
  6. 最后我不得不运行这个命令:

    $ ./build-aux/prefix-gnulib-mk --lib-name=libshill lib/gnulib.mk
    

就是这样。

【讨论】:

  • 干得好,在 Stackoverflow 上有个好的开始!很高兴您花时间在这里记录对您有用的方法。继续加油!
猜你喜欢
  • 2017-09-10
  • 1970-01-01
  • 1970-01-01
  • 2021-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-09
  • 1970-01-01
相关资源
最近更新 更多