当我执行命令包时,出现编译错误,我不这样做 找到了解决方案。
我使用os Windows 10,Ruby和Rails的版本是:
红宝石: bin:C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe 版本:ruby 2.1.5p273(2014-11-13修订版48405)[i386-mingw32]
轨: bin:C:/RailsInstaller/Ruby2.0.0/bin/rails.bat 版本:Rails 4.1.8
我打算在我的项目中安装的Gem是wubook_wired,用于WuBook API集成,称为“Wired”: https://github.com/eilers/wubook_wired
出现的错误是:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb checking for expat.h... yes checking for XML_ParserCreate() in -lexpat... no checking for XML_ParserCreate() in -lxmltok... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=C:/RailsInstaller/Ruby2.1.0/bin/ruby --with-perl-enc-map --without-perl-enc-map --with-expat-dir --without-expat-dir --with-expat-include --without-expat-include=${expat-dir}/include --with-expat-lib --without-expat-lib=${expat-dir}/lib --with-expatlib --without-expatlib --with-xmltoklib --without-xmltoklib extconf failed, exit code 1 Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/xmlparser-0.7.2.1 for inspection. Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/xmlparser-0.7.2.1/gem_make.out An error occurred while installing xmlparser (0.7.2.1), and Bundler cannot continue. Make sure that `gem install xmlparser -v '0.7.2.1'` succeeds before bundling.
mkmf.log文件是:
have_library: checking for XML_ParserCreate() in -lexpat... -------------------- no "gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lexpat -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " conftest.c: In function 't': conftest.c:16:57: error: 'XML_ParserCreate' undeclared (first use in this function) conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable] checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include 4: #include 5: 6: /*top*/ 7: extern int t(void); 8: int main(int argc, char **argv) 9: { 10: if (argc > 1000000) { 11: printf("%p", &t); 12: } 13: 14: return 0; 15: } 16: int t(void) { void ((*volatile p)()); p = (void ((*)()))XML_ParserCreate; return 0; } /* end */ "gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lexpat -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " conftest.c: In function 't': conftest.c:16:1: warning: implicit declaration of function 'XML_ParserCreate' [-Wimplicit-function-declaration] c:/railsinstaller/devkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lexpat collect2.exe: error: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include 4: #include 5: 6: /*top*/ 7: extern int t(void); 8: int main(int argc, char **argv) 9: { 10: if (argc > 1000000) { 11: printf("%p", &t); 12: } 13: 14: return 0; 15: } 16: int t(void) { XML_ParserCreate(); return 0; } /* end */ -------------------- have_library: checking for XML_ParserCreate() in -lxmltok... -------------------- no "gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lxmltok -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " conftest.c: In function 't': conftest.c:16:57: error: 'XML_ParserCreate' undeclared (first use in this function) conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable] checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include 4: #include 5: 6: /*top*/ 7: extern int t(void); 8: int main(int argc, char **argv) 9: { 10: if (argc > 1000000) { 11: printf("%p", &t); 12: } 13: 14: return 0; 15: } 16: int t(void) { void ((*volatile p)()); p = (void ((*)())) XML_ParserCreate; return 0; } /* end */ "gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lxmltok -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " conftest.c: In function 't': conftest.c:16:1: warning: implicit declaration of function 'XML_ParserCreate' [-Wimplicit-function-declaration] c:/railsinstaller/devkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lxmltok collect2.exe: error: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include 4: #include 5: 6: /*top*/ 7: extern int t(void); 8: int main(int argc, char **argv) 9: { 10: if (argc > 1000000) { 11: printf("%p", &t); 12: } 13: 14: return 0; 15: } 16: int t(void) { XML_ParserCreate(); return 0; } /* end */
我非常感谢你的帮助。
答案 0 :(得分:0)
我做了解决方案的后续步骤:
因为我在Devkit文件夹(c:\ RailsInstaller \ DevKit)中找不到libexpat.a: 文本“./i686-w64-mingw32/bin/ld.exe:找不到-lexpat”表示libexpat.a文件的引用。
我下载mingw-w64-install.exe然后安装它。
接下来我运行命令包但尚未更正。
稍后我从“C:\ Program Files(x86)\ mingw-w64 \ i686-5.1.0-posix-dwarf-rt_v4-rev0 \ mingw32 \ opt \ lib”文件夹中复制libexpat.a文件,其中mingw-w64已安装到“C:\ RailsInstaller \ DevKit \ mingw \ i686-w64-mingw32 \ lib”文件夹中。
和“Eureka”:命令包运行正常。
多数人。
请有人有更好的解决方案.....