0

这是一个到目前为止谷歌还没有很有帮助的问题:

我正在使用本机扩展的 Linux Mint 上安装 RubyGem,因此它试图在我的机器上编译它们。正如经常发生的那样,它返回一个错误,说明它在机器上没有构建扩展所需的所有工具:

Building native extensions.  This could take a while...
ERROR:  Error installing sas-helper:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
checking for expat.h... yes
checking for XML_ParserCreate() in -lexpat... yes
checking for XML_SetNotStandaloneHandler()... yes
checking for XML_SetParamEntityParsing()... yes
checking for XML_SetDoctypeDeclHandler()... yes
checking for XML_ParserReset()... yes
checking for XML_SetSkippedEntityHandler()... yes
checking for XML_GetFeatureList()... yes
checking for XML_UseForeignDTD()... yes
checking for XML_GetIdAttributeIndex()... yes
checking for ntohl() in -lsocket... no
creating Makefile

make
compiling xmlparser.c
xmlparser.c: In function ‘XMLParser_mark’:
xmlparser.c:185:16: warning: variable ‘parent’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘iterExternalEntityRefHandler’:
xmlparser.c:372:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘myExternalEntityRefHandler’:
xmlparser.c:832:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘myStartCdataSectionHandler’:
xmlparser.c:860:14: warning: variable ‘parser’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘myEndCdataSectionHandler’:
xmlparser.c:868:14: warning: variable ‘parser’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘myNotStandaloneHandler’:
xmlparser.c:898:14: warning: variable ‘parser’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘myEndDoctypeDeclHandler’:
xmlparser.c:939:14: warning: variable ‘parser’ set but not used [-Wunused-but-set-variable]
xmlparser.c: In function ‘XMLParser_parse’:
xmlparser.c:1783:2: error: format not a string literal and no format arguments [-Werror=format-security]
xmlparser.c:1832:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xmlparser.o] Error 1

我查看了谷歌,并没有发现很多与这种情况相关的东西。看来我缺少这个 ntohl() 函数,谁能告诉我在哪个 Debian 软件包中可以找到这个函数?

4

3 回答 3

1

经过一番挖掘,我找到了解决方案!

您必须设置正确的编译器标志:https ://github.com/sparklemotion/nokogiri/issues/680#issuecomment-5830358

gem install xmlparser -- --with-cflags="-Wformat-security"

root@c6d50bebf05f:/var/lib/gems/2.0.0/gems# gem install xmlparser -- --with-cflags="-Wformat-security"
Building native extensions with: '--with-cflags=-Wformat-security'
This could take a while...
Successfully installed xmlparser-0.7.2.1
Parsing documentation for xmlparser-0.7.2.1
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for /var/lib/gems/2.0.0/extensions/x86_64-linux/2.0.0/xmlparser-0.7.2.1/xmlparser.so, skipping
unable to convert "\xCD" from ASCII-8BIT to UTF-8 for README.ja, skipping
unable to convert "\xC0" from ASCII-8BIT to UTF-8 for ext/xmlparser.o, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for ext/xmlparser.so, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for lib/xmlparser.so, skipping
Installing ri documentation for xmlparser-0.7.2.1
1 gem installed
于 2016-12-16T09:24:53.250 回答
0

与在 Ubuntu 12.10 上安装 Nokogiri (1.5.2) 的问题相同,引用https://stackoverflow.com/users/65190/mike-dalessio

Ubuntu 12.10 采用 Debian 的强化包装器,其中包括一组导致此编译错误的 GCC 的默认标志。我们已经在 Nokogiri 1.5.4 及更高版本中解决了这个问题,因此您需要升级或找到自己的解决方法。

有关 Debian 强化的信息,请参见此处。http://wiki.debian.org/Hardening#DEB_BUILD_HARDENING_FORMAT_.28gcc.2BAC8-g.2B-.2B- -Wformat -Wformat-security_-Werror.3Dformat-security.29

有关 Nokogiri 团队使用的解决方案的详细信息,请参见此处。https://github.com/sparklemotion/nokogiri/issues/680

...只需复制此处的信息,以便下一个出现的人可以停止挖掘:)

于 2013-11-28T11:09:12.373 回答
0

我猜这个包是happycoders-libsocket:http ://www.happycoders.org/software/libsocket.php

于 2013-06-04T23:34:40.080 回答