rubys / nokogumbo

A Nokogiri interface to the Gumbo HTML5 parser.
Apache License 2.0
186 stars 114 forks source link

Error installing on windows 10 with ruby installer #146

Closed dsisnero closed 3 years ago

dsisnero commented 4 years ago

C:\Users\Dominic E Sisneros\source\repos\git\dsisnero\numo-narray>gem install nokogumbo --platform=ruby Temporarily enhancing PATH for MSYS/MINGW... Building native extensions. This could take a while... ERROR: Error installing nokogumbo: ERROR: Failed to build gem native extension.

current directory: c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogumbo-2.0.2/ext/nokogumbo

c:/Ruby27-x64/bin/ruby.exe -I c:/Ruby27-x64/lib/ruby/2.7.0 -r ./siteconf20200520-17996-2d18h9.rb extconf.rb checking for xmlNewDoc() in -lxml2... yes checking for nokogiri.h in c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogiri-1.10.9/ext/nokogiri... yes creating Makefile

current directory: c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogumbo-2.0.2/ext/nokogumbo make "DESTDIR=" clean

current directory: c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogumbo-2.0.2/ext/nokogumbo make "DESTDIR=" generating nokogumbo-x64-mingw32.def compiling nokogumbo.c In file included from nokogumbo.c:53: c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogiri-1.10.9/ext/nokogiri/nokogiri.h:13: warning: "_GNU_SOURCE" redefined 13 #define _GNU_SOURCE
In file included from C:/Ruby27-x64/include/ruby-2.7.0/ruby/ruby.h:24, from C:/Ruby27-x64/include/ruby-2.7.0/ruby.h:33, from nokogumbo.c:22: c:/Ruby27-x64/include/ruby-2.7.0/x64-mingw32/ruby/config.h:17: note: this is the location of the previous definition 17 #define _GNU_SOURCE 1
nokogumbo.c: In function 'parse': nokogumbo.c:505:20: warning: passing argument 1 of 'rb_ensure' from incompatible pointer type [-Wincompatible-pointer-types] 505 return rb_ensure(parse_continue, (VALUE)&args, parse_cleanup, (VALUE)&args); ^~~~~~
VALUE ()(ParseArgs ) {aka long long unsigned int ()(ParseArgs )}
In file included from C:/Ruby27-x64/include/ruby-2.7.0/ruby.h:33, from nokogumbo.c:22: C:/Ruby27-x64/include/ruby-2.7.0/ruby/ruby.h:1990:17: note: expected 'VALUE ()(VALUE)' {aka 'long long unsigned int ()(long long unsigned int)'} but argument is of type 'VALUE ()(ParseArgs )' {aka 'long long unsigned int ()(ParseArgs )'} 1990 VALUE rb_ensure(VALUE()(VALUE),VALUE,VALUE()(VALUE),VALUE); ^~~~~~~ nokogumbo.c:505:50: warning: passing argument 3 of 'rb_ensure' from incompatible pointer type [-Wincompatible-pointer-types] 505 return rb_ensure(parse_continue, (VALUE)&args, parse_cleanup, (VALUE)&args); ^~~~~
VALUE ()(ParseArgs ) {aka long long unsigned int ()(ParseArgs )}
In file included from C:/Ruby27-x64/include/ruby-2.7.0/ruby.h:33, from nokogumbo.c:22: C:/Ruby27-x64/include/ruby-2.7.0/ruby/ruby.h:1990:39: note: expected 'VALUE ()(VALUE)' {aka 'long long unsigned int ()(long long unsigned int)'} but argument is of type 'VALUE ()(ParseArgs )' {aka 'long long unsigned int ()(ParseArgs )'} 1990 VALUE rb_ensure(VALUE()(VALUE),VALUE,VALUE()(VALUE),VALUE); ^~~~~~~ nokogumbo.c: In function 'fragment': nokogumbo.c:695:13: warning: passing argument 1 of 'rb_ensure' from incompatible pointer type [-Wincompatible-pointer-types] 695 rb_ensure(fragment_continue, (VALUE)&args, parse_cleanup, (VALUE)&args); ^~~~~
VALUE ()(ParseArgs ) {aka long long unsigned int ()(ParseArgs )}
In file included from C:/Ruby27-x64/include/ruby-2.7.0/ruby.h:33, from nokogumbo.c:22: C:/Ruby27-x64/include/ruby-2.7.0/ruby/ruby.h:1990:17: note: expected 'VALUE ()(VALUE)' {aka 'long long unsigned int ()(long long unsigned int)'} but argument is of type 'VALUE ()(ParseArgs )' {aka 'long long unsigned int ()(ParseArgs )'} 1990 VALUE rb_ensure(VALUE()(VALUE),VALUE,VALUE()(VALUE),VALUE); ^~~~~~~ nokogumbo.c:695:46: warning: passing argument 3 of 'rb_ensure' from incompatible pointer type [-Wincompatible-pointer-types] 695 rb_ensure(fragment_continue, (VALUE)&args, parse_cleanup, (VALUE)&args); ^~~~~
VALUE ()(ParseArgs ) {aka long long unsigned int ()(ParseArgs )}

In file included from C:/Ruby27-x64/include/ruby-2.7.0/ruby.h:33, from nokogumbo.c:22: C:/Ruby27-x64/include/ruby-2.7.0/ruby/ruby.h:1990:39: note: expected 'VALUE ()(VALUE)' {aka 'long long unsigned int ()(long long unsigned int)'} but argument is of type 'VALUE ()(ParseArgs )' {aka 'long long unsigned int ()(ParseArgs )'} 1990 | VALUE rb_ensure(VALUE()(VALUE),VALUE,VALUE()(VALUE),VALUE); | ^~~~~~~ compiling ./../../gumbo-parser/src/ascii.c compiling ./../../gumbo-parser/src/attribute.c compiling ./../../gumbo-parser/src/char_ref.c compiling ./../../gumbo-parser/src/error.c compiling ./../../gumbo-parser/src/foreign_attrs.c compiling ./../../gumbo-parser/src/parser.c compiling ./../../gumbo-parser/src/string_buffer.c compiling ./../../gumbo-parser/src/string_piece.c compiling ./../../gumbo-parser/src/svg_attrs.c compiling ./../../gumbo-parser/src/svg_tags.c compiling ./../../gumbo-parser/src/tag.c compiling ./../../gumbo-parser/src/tag_lookup.c compiling ./../../gumbo-parser/src/tokenizer.c compiling ./../../gumbo-parser/src/token_buffer.c compiling ./../../gumbo-parser/src/utf8.c compiling ./../../gumbo-parser/src/util.c compiling ./../../gumbo-parser/src/vector.c linking shared-object nokogumbo/nokogumbo.so C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nokogumbo.o:nokogumbo.c:(.text+0x1366): undefined reference to Nokogiri_wrap_xml_document' C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nokogumbo.o:nokogumbo.c:(.rdata$.refptr.mNokogiri[.refptr.mNokogiri]+0x0): undefined reference tomNokogiri' C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nokogumbo.o:nokogumbo.c:(.rdata$.refptr.cNokogiriXmlSyntaxError[.refptr.cNokogiriXmlSyntaxError]+0x0): undefined reference to `cNokogiriXmlSyntaxError' collect2.exe: error: ld returned 1 exit status make: *** [Makefile:261: nokogumbo.so] Error 1

make failed, exit code 2

Gem files will remain installed in c:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogumbo-2.0.2 for inspection. Results logged to c:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/nokogumbo-2.0.2/gem_make.out

dsisnero commented 4 years ago

any information on how to fix this? Thanks

dsisnero commented 4 years ago

Any fix for this or suggestions? Thanks

stevecheckoway commented 4 years ago

I'm sorry I don't know much about building on Windows. I notice that your log shows Ruby26-x64 and Ruby27-x64. That's surprising to me. I'd expect the files to be linked by the same toolchain that compiled them.

dsisnero commented 4 years ago

gem_make.out

https://gist.github.com/dsisnero/26943d1b5ad0dbd489128b09b2a39e0c

Ok- this is from C:\Users\Dominic E Sisneros>ruby --version ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]

C:\Users\Dominic E Sisneros>gem environment RubyGems Environment:

dsisnero commented 4 years ago

Still have an error on 10/07/2020

gem_make.out https://gist.github.com/dsisnero/04b8421fd3056163a9d8e3730c0c6628

stevecheckoway commented 3 years ago

It looks like it's failing to create the shared object (dll on Windows) because it can't find symbols from Nokogiri. I'm not sure why that would be the case.

dsisnero commented 3 years ago

I don't know. Here's the latest test 11/30/2020 https://gist.github.com/dsisnero/e6873452ad4db221ebf98ab8d9327e3e

stevecheckoway commented 3 years ago

This is a little odd. The CI build does not find the nokogiri.h header.

checking for libxml/tree.h in ports/x86_64-w64-mingw32/libxml2/2.9.10/include/libxml2... yes
checking for nokogiri.h in D:/a/nokogumbo/nokogumbo/vendor/bundle/ruby/2.7.0/gems/nokogiri-1.10.10-x64-mingw32/ext/nokogiri... no

so presumably, it's using the slow path where building the tree goes through Ruby.

In your log, it is finding nokogiri.h

checking for libxml/tree.h in ports/x86_64-w64-mingw32/libxml2/2.9.10/include/libxml2... yes
checking for nokogiri.h in F:/windows/scoop/persist/ruby/gems/gems/nokogiri-1.10.10-x64-mingw32/ext/nokogiri... yes

In both cases, the libxml2 headers are found.

What happens if you try gem install nokogumbo -- --without-libxml2?

@flavorjones Any idea why nokogiri.h isn't being found by the CI build?

stevecheckoway commented 3 years ago

Hmm. I wonder if Windows can even work the same way macOS and Linux do here without exporting the Nokogiri and libxml2 symbols by adding __declspec(dllexport) to them or making a .def file (which extconf.rb does to export the initialization function).

If it turns out this is the issue, I can change extconf.rb to not try to link against nokogiri.so on Windows which should solve this problem (but leave Windows with the slow path).

dsisnero commented 3 years ago

Sorry, I don't know enough to help. Here's what I found https://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/ and https://www.transmissionzero.co.uk/computing/advanced-mingw-dll-topics/

On Mon, Nov 30, 2020 at 9:57 AM Stephen Checkoway notifications@github.com wrote:

Hmm. I wonder if Windows can even work the same way macOS and Linux do here without exporting the Nokogiri and libxml2 symbols https://docs.microsoft.com/en-us/cpp/build/exporting-from-a-dll?view=msvc-160 by adding __declspec(dllexport) to them or making a .def file (which extconf.rb does to export the initialization function).

If it turns out this is the issue, I can change extconf.rb to not try to link against nokogiri.so on Windows which should solve this problem (but leave Windows with the slow path).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubys/nokogumbo/issues/146#issuecomment-735910485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABQRJBYFVTOVNCNNCHOWTSSPFGVANCNFSM4NGHF3TA .

flavorjones commented 3 years ago

@flavorjones Any idea why nokogiri.h isn't being found by the CI build?

Sorry, I was hoping to find time over the weekend to look at this, and I fell woefully short of that expectation. I can't think of any good reasons why we shouldn't be able to make this work on Windows, I just need to understand what's going on. I may be able to spend time on it later this week.

flavorjones commented 3 years ago

I've got a Windows dev environment up and running now, will take a look tonight.

flavorjones commented 3 years ago

So #163 should resolve this issue; but it has its own issues (see the conversation there and at https://github.com/sparklemotion/nokogiri/issues/2167). Still working on it.

flavorjones commented 3 years ago

This should be fixed in v2.0.5 which just shipped. Closing, but please feel free to comment if you're still seeing this issue with the latest version.

dsisnero commented 3 years ago

thank you!

On Fri, Mar 19, 2021 at 6:06 AM Mike Dalessio @.***> wrote:

Closed #146 https://github.com/rubys/nokogumbo/issues/146.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubys/nokogumbo/issues/146#event-4481831560, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABQRJN54GYUMJPJV3M3KLTEM44HANCNFSM4NGHF3TA .