首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开始使用MinGW上的gnulib,对自动工具不太熟悉(够了)

开始使用MinGW上的gnulib,对自动工具不太熟悉(够了)
EN

Stack Overflow用户
提问于 2015-06-25 20:28:40
回答 1查看 2.1K关注 0票数 6

我有一些C代码是为Linux编写的,它依赖于套接字和arpa/inet.h以及libusb.h,我想在MinGW下编译它。(请注意,当前的项目只是一个非常简单的Makefile,根本不依赖于自动工具)。

使用gnulib似乎是在MinGW下编译Windows的一个好方法,我已经朝这个方向开始了,但是如果你不太熟悉自动工具,你很快就会深入到其中。

以下是我尝试过的:

代码语言:javascript
复制
$ gnulib-tool --import getsockname,getsockopt,setsockopt,socket,socketlib,sockets,socklen,sys_socket,arpa_inet,inet_ntop,inet_pton,netinet_in

它运行并在结尾给我以下信息:

代码语言:javascript
复制
Don't forget to
  - add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
  - mention "lib" in SUBDIRS in Makefile.am,
  - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
  - mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am,
  - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC,
  - invoke gl_INIT in ./configure.ac.

好的,我没有configure.ac,也没有Makefile.am,所以我创建了它们,如下所示(按照上面的说明):

代码语言:javascript
复制
$ cat Makefile.am
SUBDIRS = lib
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = m4/gnulib-cache.m4

还有..。

代码语言:javascript
复制
$ cat configure.ac
AC_INIT([configure.ac])
AC_CONFIG_FILES([lib/Makefile])
AC_PROG_CC
gl_EARLY
gl_INIT

现在,gnulib文档似乎假设您非常熟悉autotools,因此它们忽略了接下来需要使用autotools的所有说明。

从我从各种论坛中了解到的情况来看,接下来的步骤似乎是运行:

代码语言:javascript
复制
$ aclocal
$ autoconf
$ automake
$ configure

然而..。当我运行自动驾驶时,我得到了:

代码语言:javascript
复制
$ automake
configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
configure.ac: that aclocal.m4 is present in the top-level directory,
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal).
lib/Makefile.am:30: library used but `RANLIB' is undefined
lib/Makefile.am:30:   The usual way to define `RANLIB' is to add  `AC_PROG_RANLIB

‘lib/Makefile.am:30: to configure.ac' and runautoconf’。

嗯..。好吧,这可能只是我在Makefile.am中遗漏的一些东西(因为我不完全确定Makefile.am应该包含什么).所以退一步..。我应该能够运行上面在autoconf步骤中创建的配置文件:

代码语言:javascript
复制
$ ./configure

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
./configure: line 2497: gl_EARLY: command not found
./configure: line 2498: gl_INIT: command not found
rm: cannot lstat `conftest.exe': Permission denied

根据我在谷歌上看到的内容,似乎gl_EARLY和gl_INIT应该由添加到Makefile.am文件中的行( ACLOCAL_AMFLAGS = -I m4)来处理,但此时我并不完全确定自己是否正确地完成了自动工具部分工作。有人能指出我在这里做错了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-29 20:31:05

  1. AC_CONFIG_MACRO_DIR([m4])添加到configure.ac中,它将在m4目录中找到gnulib宏。
  2. 添加AM_INIT_AUTOMAKE
  3. AC_CONFIG_FILES不仅应该包含gnulib Makefile,还应该包含Makefile
  4. 您可以通过对autoreconf的单次调用重新生成所有内容
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31060183

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档