在Windows上编译:为什么cygwin可以';我不认识gettext?
我试图在Windows上使用cygwin编译enc2ly(),但它给出了错误。当我键入在Windows上编译:为什么cygwin可以';我不认识gettext?,windows,cygwin,gettext,core-foundation,libc,Windows,Cygwin,Gettext,Core Foundation,Libc,我试图在Windows上使用cygwin编译enc2ly(),但它给出了错误。当我键入/configure时,结果如下: checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for ga
/configure
时,结果如下:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
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
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for ld used by GCC... /usr/i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for shared library run path origin... done
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... no
checking for iconv... yes
checking for working iconv... yes
checking how to link with libiconv... -liconv
checking for GNU gettext in libintl... yes
checking whether to use NLS... yes
checking where the gettext function comes from... external libintl
checking how to link with libintl... -lintl
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for error_at_line... yes
checking for memset... yes
checking for strstr... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dok/Makefile
config.status: creating iloj/Makefile
config.status: creating kod/Makefile
config.status: creating enc2ly.spec
config.status: creating enc2ly.lsm
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
当我键入make
时,它失败。我怀疑问题就在这里:
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... no
那么,丢失了哪些软件包?还是另一回事?无论如何,谢谢你
----------------------编辑-------------------------
我使用了/configure--disable nls
,它可以正常工作。所以问题真的是gettext
checking for GNU gettext in libc... no
我已经安装了gettext包。少了什么?我必须解决这个问题,因为程序的主要语言是世界语 我花了一些时间(可能太多)玩这个,我已经设法把它建立起来了
在Ubuntu12.04上,它构建了开箱即用的.tar.gz
文件,查找并使用GNU gettext没有问题。在Cygwin上,我犯了和你一样的错误
一个区别是,在Cygwin上,使用gettext
的程序需要链接到-lintl
;在Ubuntu上,它没有(显然,gettext
在标准C库中)
在对configure
脚本进行了一些修改之后,我想出了以下解决方法:
首先,在调用/configure
之前,将环境变量$LIBS
设置为“-lintl”
其次,Ubuntu库(而不是Cygwin库)似乎提供了一个未记录的符号\u nl\u domain\u绑定
,由配置
生成的小测试程序依赖于该符号。因此,我破解了configure
脚本,在生成的C测试程序中注释掉对\u nl\u domain\u绑定的引用
黑客configure
不是解决此问题的正确方法;configure
脚本由其他工具生成(在源代码发布之前)。您需要熟悉GNU autoconf的人来提出更好的解决方案。而configure
应该能够自行检测到对-lintl
选项的需要
这里有一件非常奇怪的事情:源代码树中唯一出现的-lintl
是enc2ly-0.2/m4/gettext.m4
中的以下行:
LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
它通过删除任何出现的-lintl
来修改$LIBS
。如果有什么评论可以解释这一点的话,很可能是世界语。(除了开玩笑,我从没想过我会这么说。)
所以我注释掉了那一行,它成功了,生成了一个enc2ly.exe
文件,如果我在没有参数的情况下调用它,它至少会打印一条用法消息:
$ /usr/local/apps/enc2ly-0.2/bin/enc2ly.exe
Dosieroj sukcese procezitaj: 0 (domaĝe!)
$
是的,那是世界语;谷歌将其翻译成,但并非完全成功
Files successfully procezitaj: 0 (domaĝe!)
我将我的修改保存在本地Git存储库中。下面是git diff的输出:
diff --git a/configure b/configure
index 1605a50..8d1a1b7 100755
--- a/configure
+++ b/configure
@@ -5162,12 +5162,12 @@ else
#include <libintl.h>
$gt_revision_test_code
extern int _nl_msg_cat_cntr;
-extern int *_nl_domain_bindings;
+/* extern int *_nl_domain_bindings; */
int
main ()
{
bindtextdomain ("", "");
-return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr /* + *_nl_domain_bindings */
;
return 0;
}
diff --git a/m4/gettext.m4 b/m4/gettext.m4
index f84e6a5..6c77c3a 100644
--- a/m4/gettext.m4
+++ b/m4/gettext.m4
@@ -247,7 +247,7 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a
USE_INCLUDED_LIBINTL=yes
LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
- LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
+# LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
fi
CATOBJEXT=
diff--git a/配置b/配置
索引1605a50..8d1a1b7 100755
---a/配置
+++b/配置
@@-5162,12+5162,12@@else
#包括
$gt\u版本\u测试\u代码
外部国际信息中心;
-extern int*_nl_domain_绑定;
+/*extern int*_nl_domain_绑定*/
int
主要()
{
bindtextdomain(“,”);
-返回*gettext(“”$gt\u表达式\u测试\u代码+\u nl\u msg\u cat\u cntr+*\u nl\u域\u绑定
+return*gettext(“”$gt\u expression\u test\u code++\u nl\u msg\u cat\u cntr/*++*\u nl\u domain\u绑定*/
;
返回0;
}
diff——git a/m4/gettext.m4 b/m4/gettext.m4
索引f84e6a5..6c77c3a 100644
---a/m4/gettext.m4
+++b/m4/gettext.m4
@@-247,7+247,7@@return*gettext(“”$gt\u expression\u test\u code+\u nl\u msg\u cat\u cntr+*\u nl\u expand\u a
使用包含的内容
LIBINTL=“ifelse([$3],\${top\u builddir}/intl,[$3])/LIBINTL.[]gt\u libtool\u suffix\u prefix[]a$LIBICONV$LIBTHREAD”
LTLIBINTL=“ifelse([$3],][,\${top\u builddir}/intl,[$3])/libintl.[]gt\u libtool\u suffix\u prefix[]a$LTLIBICONV$LTLIBTHREAD”
-LIBS=`echo“$LIBS”| sed-e's/-lintl/'-e's/^/'-e's/$/'`
+#LIBS=`echo“$LIBS”| sed-e's/-lintl/'-e's/^/'-e's/$/'`
fi
卡托布杰特=
抓取enc2ly-0.2.tar.gz
,将其解包,应用上述更改(手动操作非常简单),将环境变量$LIBS
设置为-lintl
,正常构建和安装,应该就可以了
您可能想就这个问题与维护人员联系;我确信他们希望实施一个比这更干净的解决方案。问题是这个问题仍然是世界语(我不知道你是否注意到我对这个问题的编辑)。但至少它能工作,而且语言不是真正的障碍,因为这是一个简单的程序,谷歌翻译就在那里。正如你所说,我(我们)在这件事上花了太多时间。也许我会尝试使用minGW构建它,或者让我的一些朋友在Linux上交叉编译。无论如何,谢谢你的时间和努力。