brianmario / charlock_holmes

Character encoding detection, brought to you by ICU
MIT License
1.04k stars 141 forks source link

Install failure [Ruby 2.1.3] [Windows 7] #84

Open octylFractal opened 9 years ago

octylFractal commented 9 years ago

Install fails on Windows because there's no way to get icu. Also, this is going in a Bundler Gemfile, so I can't really pass a special install parameter.

rlisowski commented 9 years ago

did you try bundle config build.charlock_holmes --with-icu-dir=/path/to/installed/icu4c before bundle install?

ikappas commented 9 years ago

I am having the same frustrating issue on Windows 8.1 Pro - Ruby 2.1.5p273 trying to install charlock_holmes ver.0.6.9.4

C:/Ruby21/bin/ruby.exe extconf.rb
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
  -- tar zxvf file-5.08.tar.gz
  -- ./configure --prefix=C:/Ruby21/lib/ruby/gems/2.1.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/dst/ --disable-shared --enable-static --with-pic
*** 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:/Ruby21/bin/ruby
    --with-icu-dir
    --without-icu-dir
    --with-icu-include
    --without-icu-include=${icu-dir}/include
    --with-icu-lib
    --without-icu-lib=${icu-dir}/lib
    --with-icui18nlib
    --without-icui18nlib
    --with-icui18nlib
    --without-icui18nlib
extconf.rb:7:in `sys': ./configure --prefix=C:/Ruby21/lib/ruby/gems/2.1.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/dst/ --disable-shared --enable-static --with-pic failed, please report issue on http://github.com/brianmario/charlock_holmes (RuntimeError)
    from extconf.rb:60:in `block (2 levels) in <main>'
    from extconf.rb:59:in `chdir'
    from extconf.rb:59:in `block in <main>'
    from extconf.rb:55:in `chdir'
    from extconf.rb:55:in `<main>'

extconf failed, exit code 1

The installation breaks while trying to configure the file-5.08 dependency. After many hours at it I found that the regex.h file is not included in the file-5.08 src and that broke the build process. I used the C_INCLUDE_HEADERS environment variable an set it to C:\RubyDevkit\mingw\include where the regex.h header is located and I managed to build file-5.08 manually like so:

C:\Ruby21\lib\ruby\gems\2.1.0\gems\charlock_holmes-0.6.9.4\ext\charlock_holmes\src\file-5.08\./configure --prefix=C:/Ruby21/lib/ruby/gems/2.1.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/dst/ --disable-shared --enable-static --with-pic
C:\Ruby21\lib\ruby\gems\2.1.0\gems\charlock_holmes-0.6.9.4\ext\charlock_holmes\src\file-5.08\make
C:\Ruby21\lib\ruby\gems\2.1.0\gems\charlock_holmes-0.6.9.4\ext\charlock_holmes\src\file-5.08\make install

For some reason though using either :

gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=c:/RubyDevKit/mingw

or

bundle config build.charlock_holmes --with-icu-dir=c:/RubyDevKit/mingw
bundle install

fails

mkmf.log is not very helpful

have_library: checking for main() in -licui18n... -------------------- yes

"gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/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:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/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:/Ruby21/lib -L.      -lmsvcrt-ruby210 -licui18n  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
conftest.c: In function 't':
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 <winsock2.h>
 4: #include <windows.h>
 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 ((*)()))main; return 0; }
/* end */

--------------------

have_library: checking for main() in -licui18n... -------------------- yes

"gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/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:/Ruby21/lib -L.     -licui18n  -lmsvcrt-ruby210 -licui18n -licui18n  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
conftest.c: In function 't':
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 <winsock2.h>
 4: #include <windows.h>
 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 ((*)()))main; return 0; }
/* end */

--------------------

have_header: checking for unicode/ucnv.h... -------------------- yes

"gcc -E -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/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 -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <unicode/ucnv.h>
/* end */

--------------------

"tar zxvf file-5.08.tar.gz"
file-5.08/m4/libtool.m4
file-5.08/m4/ltoptions.m4
file-5.08/m4/ltsugar.m4
file-5.08/m4/ltversion.m4
file-5.08/m4/lt~obsolete.m4
file-5.08/README
file-5.08/acinclude.m4
file-5.08/configure.ac
file-5.08/aclocal.m4
file-5.08/Makefile.am
file-5.08/Makefile.in
file-5.08/config.h.in
file-5.08/configure
file-5.08/AUTHORS
file-5.08/COPYING
file-5.08/ChangeLog
file-5.08/INSTALL
file-5.08/NEWS
file-5.08/TODO
file-5.08/compile
file-5.08/config.guess
file-5.08/config.sub
file-5.08/depcomp
file-5.08/install-sh
file-5.08/ltmain.sh
file-5.08/missing
file-5.08/MAINT
file-5.08/src/magic.h
file-5.08/src/Makefile.am
file-5.08/src/Makefile.in
file-5.08/src/asprintf.c
file-5.08/src/getline.c
file-5.08/src/getopt_long.c
file-5.08/src/strlcat.c
file-5.08/src/strlcpy.c
file-5.08/src/vasprintf.c
file-5.08/src/magic.c
file-5.08/src/apprentice.c
file-5.08/src/softmagic.c
file-5.08/src/ascmagic.c
file-5.08/src/encoding.c
file-5.08/src/compress.c
file-5.08/src/is_tar.c
file-5.08/src/readelf.c
file-5.08/src/print.c
file-5.08/src/fsmagic.c
file-5.08/src/funcs.c
file-5.08/src/file.h
file-5.08/src/names.h
file-5.08/src/readelf.h
file-5.08/src/tar.h
file-5.08/src/apptype.c
file-5.08/src/file_opts.h
file-5.08/src/elfclass.h
file-5.08/src/mygetopt.h
file-5.08/src/cdf.c
file-5.08/src/cdf_time.c
file-5.08/src/readcdf.c
file-5.08/src/cdf.h
file-5.08/src/file.c
file-5.08/magic/Magdir/acorn
file-5.08/magic/Magdir/adi
file-5.08/magic/Magdir/adventure
file-5.08/magic/Magdir/allegro
file-5.08/magic/Magdir/alliant
file-5.08/magic/Magdir/amanda
file-5.08/magic/Magdir/amigaos
file-5.08/magic/Magdir/animation
file-5.08/magic/Magdir/apl
file-5.08/magic/Magdir/apple
file-5.08/magic/Magdir/applix
file-5.08/magic/Magdir/archive
file-5.08/magic/Magdir/asterix
file-5.08/magic/Magdir/att3b
file-5.08/magic/Magdir/audio
file-5.08/magic/Magdir/basis
file-5.08/magic/Magdir/bflt
file-5.08/magic/Magdir/blcr
file-5.08/magic/Magdir/blender
file-5.08/magic/Magdir/blit
file-5.08/magic/Magdir/bout
file-5.08/magic/Magdir/bsdi
file-5.08/magic/Magdir/bsi
file-5.08/magic/Magdir/btsnoop
file-5.08/magic/Magdir/c-lang
file-5.08/magic/Magdir/c64
file-5.08/magic/Magdir/cad
file-5.08/magic/Magdir/cafebabe
file-5.08/magic/Magdir/cddb
file-5.08/magic/Magdir/chord
file-5.08/magic/Magdir/cisco
file-5.08/magic/Magdir/citrus
file-5.08/magic/Magdir/clarion
file-5.08/magic/Magdir/claris
file-5.08/magic/Magdir/clipper
file-5.08/magic/Magdir/commands
file-5.08/magic/Magdir/communications
file-5.08/magic/Magdir/compress
file-5.08/magic/Magdir/console
file-5.08/magic/Magdir/convex
file-5.08/magic/Magdir/cracklib
file-5.08/magic/Magdir/ctags
file-5.08/magic/Magdir/dact
file-5.08/magic/Magdir/database
file-5.08/magic/Magdir/diamond
file-5.08/magic/Magdir/diff
file-5.08/magic/Magdir/digital
file-5.08/magic/Magdir/dolby
file-5.08/magic/Magdir/dump
file-5.08/magic/Magdir/dyadic
file-5.08/magic/Magdir/ebml
file-5.08/magic/Magdir/editors
file-5.08/magic/Magdir/efi
file-5.08/magic/Magdir/elf
file-5.08/magic/Magdir/encore
file-5.08/magic/Magdir/epoc
file-5.08/magic/Magdir/erlang
file-5.08/magic/Magdir/esri
file-5.08/magic/Magdir/fcs
file-5.08/magic/Magdir/filesystems
file-5.08/magic/Magdir/flash
file-5.08/magic/Magdir/fonts
file-5.08/magic/Magdir/fortran
file-5.08/magic/Magdir/frame
file-5.08/magic/Magdir/freebsd
file-5.08/magic/Magdir/fsav
file-5.08/magic/Magdir/games
file-5.08/magic/Magdir/gcc
file-5.08/magic/Magdir/geo
file-5.08/magic/Magdir/geos
file-5.08/magic/Magdir/gimp
file-5.08/magic/Magdir/gnome-keyring
file-5.08/magic/Magdir/gnu
file-5.08/magic/Magdir/gnumeric
file-5.08/magic/Magdir/grace
file-5.08/magic/Magdir/graphviz
file-5.08/magic/Magdir/gringotts
file-5.08/magic/Magdir/hitachi-sh
file-5.08/magic/Magdir/hp
file-5.08/magic/Magdir/human68k
file-5.08/magic/Magdir/ibm370
file-5.08/magic/Magdir/ibm6000
file-5.08/magic/Magdir/iff
file-5.08/magic/Magdir/images
file-5.08/magic/Magdir/inform
file-5.08/magic/Magdir/intel
file-5.08/magic/Magdir/interleaf
file-5.08/magic/Magdir/island
file-5.08/magic/Magdir/ispell
file-5.08/magic/Magdir/isz
file-5.08/magic/Magdir/java
file-5.08/magic/Magdir/jpeg
file-5.08/magic/Magdir/karma
file-5.08/magic/Magdir/kde
file-5.08/magic/Magdir/kml
file-5.08/magic/Magdir/lecter
file-5.08/magic/Magdir/lex
file-5.08/magic/Magdir/lif
file-5.08/magic/Magdir/linux
file-5.08/magic/Magdir/lisp
file-5.08/magic/Magdir/llvm
file-5.08/magic/Magdir/lua
file-5.08/magic/Magdir/luks
file-5.08/magic/Magdir/mach
file-5.08/magic/Magdir/macintosh
file-5.08/magic/Magdir/magic
file-5.08/magic/Magdir/mail.news
file-5.08/magic/Magdir/maple
file-5.08/magic/Magdir/mathcad
file-5.08/magic/Magdir/mathematica
file-5.08/magic/Magdir/matroska
file-5.08/magic/Magdir/mcrypt
file-5.08/magic/Magdir/mercurial
file-5.08/magic/Magdir/metastore
file-5.08/magic/Magdir/mime
file-5.08/magic/Magdir/mips
file-5.08/magic/Magdir/mirage
file-5.08/magic/Magdir/misctools
file-5.08/magic/Magdir/mkid
file-5.08/magic/Magdir/mlssa
file-5.08/magic/Magdir/mmdf
file-5.08/magic/Magdir/modem
file-5.08/magic/Magdir/motorola
file-5.08/magic/Magdir/mozilla
file-5.08/magic/Magdir/msdos
file-5.08/magic/Magdir/msooxml
file-5.08/magic/Magdir/msvc
file-5.08/magic/Magdir/mup
file-5.08/magic/Magdir/natinst
file-5.08/magic/Magdir/ncr
file-5.08/magic/Magdir/netbsd
file-5.08/magic/Magdir/netscape
file-5.08/magic/Magdir/netware
file-5.08/magic/Magdir/news
file-5.08/magic/Magdir/nitpicker
file-5.08/magic/Magdir/oasis
file-5.08/magic/Magdir/ocaml
file-5.08/magic/Magdir/octave
file-5.08/magic/Magdir/ole2compounddocs
file-5.08/magic/Magdir/olf
file-5.08/magic/Magdir/os2
file-5.08/magic/Magdir/os400
file-5.08/magic/Magdir/os9
file-5.08/magic/Magdir/osf1
file-5.08/magic/Magdir/palm
file-5.08/magic/Magdir/parix
file-5.08/magic/Magdir/parrot
file-5.08/magic/Magdir/pbm
file-5.08/magic/Magdir/pdf
file-5.08/magic/Magdir/pdp
file-5.08/magic/Magdir/perl
file-5.08/magic/Magdir/pgp
file-5.08/magic/Magdir/pkgadd
file-5.08/magic/Magdir/plan9
file-5.08/magic/Magdir/plus5
file-5.08/magic/Magdir/printer
file-5.08/magic/Magdir/project
file-5.08/magic/Magdir/psdbms
file-5.08/magic/Magdir/pulsar
file-5.08/magic/Magdir/pyramid
file-5.08/magic/Magdir/python
file-5.08/magic/Magdir/revision
file-5.08/magic/Magdir/riff
file-5.08/magic/Magdir/rinex
file-5.08/magic/Magdir/rpm
file-5.08/magic/Magdir/rtf
file-5.08/magic/Magdir/ruby
file-5.08/magic/Magdir/sc
file-5.08/magic/Magdir/sccs
file-5.08/magic/Magdir/scientific
file-5.08/magic/Magdir/securitycerts
file-5.08/magic/Magdir/selinux
file-5.08/magic/Magdir/sendmail
file-5.08/magic/Magdir/sequent
file-5.08/magic/Magdir/sgi
file-5.08/magic/Magdir/sgml
file-5.08/magic/Magdir/sharc
file-5.08/magic/Magdir/sinclair
file-5.08/magic/Magdir/sisu
file-5.08/magic/Magdir/sketch
file-5.08/magic/Magdir/smalltalk
file-5.08/magic/Magdir/sniffer
file-5.08/magic/Magdir/softquad
file-5.08/magic/Magdir/spec
file-5.08/magic/Magdir/spectrum
file-5.08/magic/Magdir/sql
file-5.08/magic/Magdir/ssh
file-5.08/magic/Magdir/ssl
file-5.08/magic/Magdir/sun
file-5.08/magic/Magdir/sysex
file-5.08/magic/Magdir/tcl
file-5.08/magic/Magdir/teapot
file-5.08/magic/Magdir/terminfo
file-5.08/magic/Magdir/tex
file-5.08/magic/Magdir/tgif
file-5.08/magic/Magdir/ti-8x
file-5.08/magic/Magdir/timezone
file-5.08/magic/Magdir/troff
file-5.08/magic/Magdir/tuxedo
file-5.08/magic/Magdir/typeset
file-5.08/magic/Magdir/unicode
file-5.08/magic/Magdir/unknown
file-5.08/magic/Magdir/uuencode
file-5.08/magic/Magdir/varied.out
file-5.08/magic/Magdir/varied.script
file-5.08/magic/Magdir/vax
file-5.08/magic/Magdir/vicar
file-5.08/magic/Magdir/virtual
file-5.08/magic/Magdir/virtutech
file-5.08/magic/Magdir/visx
file-5.08/magic/Magdir/vms
file-5.08/magic/Magdir/vmware
file-5.08/magic/Magdir/vorbis
file-5.08/magic/Magdir/vxl
file-5.08/magic/Magdir/warc
file-5.08/magic/Magdir/weak
file-5.08/magic/Magdir/windows
file-5.08/magic/Magdir/wireless
file-5.08/magic/Magdir/wordprocessors
file-5.08/magic/Magdir/wsdl
file-5.08/magic/Magdir/xdelta
file-5.08/magic/Magdir/xenix
file-5.08/magic/Magdir/xilinx
file-5.08/magic/Magdir/xo65
file-5.08/magic/Magdir/xwindows
file-5.08/magic/Magdir/zilog
file-5.08/magic/Magdir/zyxel
file-5.08/magic/Makefile.am
file-5.08/magic/Makefile.in
file-5.08/magic/Header
file-5.08/magic/Localstuff
file-5.08/tests/README
file-5.08/tests/Makefile.am
file-5.08/tests/Makefile.in
file-5.08/tests/test.c
file-5.08/tests/gedcom.magic
file-5.08/tests/gedcom.testfile
file-5.08/tests/gedcom.result
file-5.08/doc/Makefile.am
file-5.08/doc/Makefile.in
file-5.08/doc/file.man
file-5.08/doc/magic.man
file-5.08/doc/libmagic.man
file-5.08/python/README
file-5.08/python/Makefile.am
file-5.08/python/Makefile.in
file-5.08/python/example.py
file-5.08/python/magic.py
file-5.08/python/setup.py
"./configure --prefix=C:/Ruby21/lib/ruby/gems/2.1.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/dst/ --disable-shared --enable-static --with-pic"
ferventcoder commented 9 years ago

Note: I tried bundle config and installing the gem without bundler based on the instructions on the readme.

Here's a log from an attempt with 1.9.3 (I also tried with 2.1.5):


Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        C:/tools/ruby193/bin/ruby.exe extconf.rb --with-icu-dir=c:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu checking for main() in -licui18n... no
which: no brew in (.;C:\tools\DevKit\bin;C:\tools\DevKit\mingw\bin;C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\tools\pik\;C:\tools\ruby193\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;c:\Program Files\Puppet Labs\Puppet\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\GitExtensions\)
checking for main() in -licui18n... no

***************************************************************************************
*********** icu required (brew install icu4c or apt-get install libicu-dev) ***********
***************************************************************************************
*** 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:/tools/ruby193/bin/ruby
        --with-icu-dir
        --with-icu-include
        --without-icu-include=${icu-dir}/include
        --with-icu-lib
        --without-icu-lib=${icu-dir}/lib
        --with-icui18nlib
        --without-icui18nlib
        --with-icui18nlib
        --without-icui18nlib

Gem files will remain installed in C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/charlock_holmes-0.7.3 for inspection.
Results logged to C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/charlock_holmes-0.7.3/ext/charlock_holmes/gem_make.out
An error occurred while installing charlock_holmes (0.7.3), and Bundler cannot
continue.
Make sure that `gem install charlock_holmes -v '0.7.3'` succeeds before
bundling.

mkmf.log

have_library: checking for main() in -licui18n... -------------------- no

"gcc -o conftest -IC:/tools/ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/tools/ruby193/include/ruby-1.9.1/ruby/backward -IC:/tools/ruby193/include/ruby-1.9.1 -I. -Ic:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/include -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/tools/ruby193/lib -Lc:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/lib -L.   -march=i486   -lmsvcrt-ruby191  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"gcc -o conftest -IC:/tools/ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/tools/ruby193/include/ruby-1.9.1/ruby/backward -IC:/tools/ruby193/include/ruby-1.9.1 -I. -Ic:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/include -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/tools/ruby193/lib -Lc:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/lib -L.   -march=i486   -lmsvcrt-ruby191 -licui18n  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:53: error: 'main' undeclared (first use in this function)
conftest.c:7:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"gcc -o conftest -IC:/tools/ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/tools/ruby193/include/ruby-1.9.1/ruby/backward -IC:/tools/ruby193/include/ruby-1.9.1 -I. -Ic:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/include -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/tools/ruby193/lib -Lc:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/lib -L.   -march=i486   -lmsvcrt-ruby191 -licui18n  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:1: warning: implicit declaration of function 'main'
conftest.c:10:6: warning: 'argc' is used uninitialized in this function
conftest.c:7:5: note: 'argc' was declared here
c:/tools/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -licui18n
collect2: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { main(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_library: checking for main() in -licui18n... -------------------- no

"gcc -o conftest -IC:/tools/ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/tools/ruby193/include/ruby-1.9.1/ruby/backward -IC:/tools/ruby193/include/ruby-1.9.1 -I. -Ic:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/include -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/tools/ruby193/lib -Lc:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/lib -L.   -march=i486   -lmsvcrt-ruby191 -licui18n  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:53: error: 'main' undeclared (first use in this function)
conftest.c:7:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"gcc -o conftest -IC:/tools/ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/tools/ruby193/include/ruby-1.9.1/ruby/backward -IC:/tools/ruby193/include/ruby-1.9.1 -I. -Ic:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/include -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/tools/ruby193/lib -Lc:/Users/Administrator/Downloads/icu4c-50_1_2-Win32-msvc10/icu/lib -L.   -march=i486   -lmsvcrt-ruby191 -licui18n  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:1: warning: implicit declaration of function 'main'
conftest.c:10:6: warning: 'argc' is used uninitialized in this function
conftest.c:7:5: note: 'argc' was declared here
c:/tools/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -licui18n
collect2: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { main(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------
madprog commented 9 years ago

I managed to install charlock_holmes on a Windows 8.1 by following these instructions.

Compile a suitable ICU

  1. Download the sources of ICU on http://site.icu-project.org/download (I took icu4c-55_1-src.zip) and extract them somewhere
  2. Go to C:\DevKit and run msys.bat
  3. Move to the source directory (beware: you are in a MSYS environment, so you have to replace your C:\ by /c/. For instance, cd /c/Users/madprog/Desktop/icu/source
  4. Run runConfigureICU MinGW. It should check the compilation environment and tell you something like ICU for C/C++ 55.1 is ready to be built., followed by notes about your Make version.
  5. Run make -j 2 (or more if you have more CPU cores) and get a coffee.
  6. Run make install DESTDIR=$PWD/dist to install the libraries in a subfolder.
  7. Check that the libraries and includes files are in dist/usr/local.

Get libz for MinGW

  1. Download the binary package from sourceforge You want libz-1.2.7-1-mingw32-dev.tar.lzma.
  2. Extract its lib/libz.a to C:\DevKit\mingw\lib (or wherever you installed DevKit)

Install your gem

gem install charlock_holmes -- \
    --with-icu-dir=C:\Users\madprog\Desktop\icu\sources\dist\usr\local \
    --with-icui18nlib=icuin \
    --with-icudatalib=icudt

or

bundle config build.charlock_holmes \
    --with-icu-dir=C:\Users\madprog\Desktop\icu\sources\dist\usr\local \
    --with-icui18nlib=icuin \
    --with-icudatalib=icudt
bundle install

I hope this will be useful to someone :)

daniel-rikowski commented 8 years ago

Thank you, this really was very helpful.

trevmex commented 7 years ago

Oh my gosh, that worked. Thank you so much, madprog!

neakni commented 5 years ago

But, Not install on Windows _10_64x

An error occurred while installing charlock_holmes (0.7.6), and Bundler cannot continue. Make sure that gem install charlock_holmes -v '0.7.6' succeeds before bundling.

Impensa commented 5 years ago

Has anyone been able to get this working for ruby 2.4 and later? Without DevKit, the helpful instructions from @madprog are no longer applicable. Stuck trying to get my build running locally.

Also not sure how relevant madprogs steps are now since the icu repo now includes pre-built windows binaries:

https://github.com/unicode-org/icu/releases/tag/release-64-1

However including them in PATH prior to running: gem install charlock_holmes -v '0.7.6' still fails.

daniel-rikowski commented 5 years ago

This is what I've been doing ever since RubyInstaller2 was available:

ridk exec pacman -S mingw-w64-x86_64-icu icu-devel icu

Then:

gem install charlock_holmes -- --with-icui18nlib=icuin --with-icudatalib=icudt

Perhaps you need these lines in your script as well: (e.g. in boot.rb in a Rails application)

require 'ruby_installer/runtime'
RubyInstaller::Runtime.enable_dll_search_paths
RubyInstaller::Runtime.enable_msys_apps

But try first without them, I'm using them in a large Rails app with a few other C-based gems (libgeos, libmagic), I'm not sure they are actually required for charlock_holmes.

BigBlueHat commented 5 years ago

Thanks @daniel-rikowski that gem install line did the trick! It'd be great to have this fixed in the code directly (if possible)! Thanks again. 😃

rubin55 commented 4 years ago

Thanks @daniel-rikowski ! I do note that icu and icu-devel are not required; i installed charlock_holmes 0.7.7 succesfully with:

ridk exec pacman -S mingw64/mingw-w64-x86_64-icu
gem install charlock_holmes -- --with-icui18nlib=icuin --with-icudatalib=icudt

Also, as a note, if you get errors like:

Makefile:269: *** multiple target patterns.  Stop.

...then you've probably installed Ruby in a path with spaces ("C:\Program Files" anyone). I ran into that which was somewhat confusing.

Ruthvik1008 commented 4 years ago

@rubin55 I'm still having issues with installation on Windows 10. Was there anything else you did before running the commands above?

Hollowname commented 2 years ago
gem install charlock_holmes -- --with-icui18nlib=icuin --with-icudatalib=icudt

@Ruthvik1008 did you find another way?