ohler55 / ox

Ruby Optimized XML Parser
http://www.ohler.com/ox
MIT License
900 stars 76 forks source link

2.14.15 cant be installed on windows #332

Closed alexanderfast closed 1 year ago

alexanderfast commented 1 year ago

Error output from gem install:

> gem install ox -v '2.14.15' --source 'https://rubygems.org/'
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing ox:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ox-2.14.15/ext/ox
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r ./siteconf20230411-23044-282kiv.rb extconf.rb
>>>>> Creating Makefile for ruby version 3.1.1 on x64-mingw-ucrt <<<<<
checking for rb_time_timespec()... yes
checking for rb_struct_alloc_noinit()... yes
checking for rb_obj_encoding()... yes
checking for rb_ivar_foreach()... yes
checking for rb_ext_ractor_safe() in ruby.h... yes
checking for pthread_mutex_init()... yes
checking for rb_enc_interned_str()... yes
checking for rb_time_nano_new()... yes
checking for index()... no
checking for ruby/st.h... yes
checking for sys/uio.h... no
checking for struct tm.tm_gmtoff... no
creating Makefile
rm: cannot remove 'mkmf.log': Device or resource busy
make: [Makefile:176: clean] Error 1 (ignored)

current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ox-2.14.15/ext/ox
make DESTDIR\= clean

current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ox-2.14.15/ext/ox
make DESTDIR\=
generating ox-x64-mingw-ucrt.def
compiling base64.c
compiling builder.c
compiling cache.c
compiling cache8.c
compiling dump.c
compiling err.c
compiling gen_load.c
compiling hash_load.c
compiling intern.c
compiling obj_load.c
compiling ox.c
compiling parse.c
compiling sax.c
sax.c: In function 'read_element_start':
sax.c:871:21: warning: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
  871 |             ename = strndup(dr->buf.str, nlen);
      |                     ^~~~~~~
sax.c:871:21: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-mismatch]
compiling sax_as.c
compiling sax_buf.c
sax_buf.c: In function 'read_from_str':
sax_buf.c:201:5: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
  201 |     strncpy(buf->tail, buf->in.str, cnt);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sax_buf.c:197:11: note: length computed here
  197 |     cnt = strlen(buf->in.str) + 1;
      |           ^~~~~~~~~~~~~~~~~~~
compiling sax_hint.c
compiling slotcache.c
compiling special.c
linking shared-object ox.so
C:/Ruby31-x64/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: sax.o:sax.c:(.text+0x5195): undefined reference to `strndup'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:263: ox.so] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ox-2.14.15 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/ox-2.14.15/gem_make.out

Expected to see something like:

> gem install ox -v '2.14.14' --source 'https://rubygems.org/'
Fetching ox-2.14.14.gem
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed ox-2.14.14
Parsing documentation for ox-2.14.14
unknown encoding name ""UTF-8"" for README.md, skipping
Installing ri documentation for ox-2.14.14
Done installing documentation for ox after 1 seconds
1 gem installed

My ruby version:

> ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]

Old version still works, so this one just prevents upgrades.

ohler55 commented 1 year ago

Nice that you also provided the fix. Thanks.