brianmario / charlock_holmes

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

Unable to install 0.7.5 with icu4c 61.1 #126

Closed ikappas closed 6 years ago

ikappas commented 6 years ago

Installing charlock_holmes 0.7.5 with icu4c 61.1 fails with the following errors:

$ gem install charlock_holmes -v '0.7.5' -- --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11

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

    current directory: /usr/local/Cellar/rbenv/1.1.1/versions/2.3.6/lib/ruby/gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
/usr/local/opt/rbenv/versions/2.3.6/bin/ruby -r ./siteconf20180329-5445-1f2zlnr.rb extconf.rb
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
checking for main() in -lz... yes
checking for main() in -licuuc... yes
checking for main() in -licudata... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/opt/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/charlock_holmes-0.7.5/mkmf.log

current directory: /usr/local/Cellar/rbenv/1.1.1/versions/2.3.6/lib/ruby/gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR=" clean

current directory: /usr/local/Cellar/rbenv/1.1.1/versions/2.3.6/lib/ruby/gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR="
compiling ext.c
compiling encoding_detector.c
compiling converter.c
compiling transliterator.cpp
transliterator.cpp:39:3: error: unknown type name 'StringEnumeration'; did you mean 'icu_61::StringEnumeration'?
  StringEnumeration *id_list;
  ^~~~~~~~~~~~~~~~~
  icu_61::StringEnumeration
/usr/local/include/unicode/strenum.h:57:20: note: 'icu_61::StringEnumeration' declared here
class U_COMMON_API StringEnumeration : public UObject {
                   ^
transliterator.cpp:47:13: error: use of undeclared identifier 'Transliterator'; did you mean 'icu_61::Transliterator'?
  id_list = Transliterator::getAvailableIDs(status);
            ^~~~~~~~~~~~~~
            icu_61::Transliterator
/usr/local/include/unicode/translit.h:243:18: note: 'icu_61::Transliterator' declared here
class U_I18N_API Transliterator : public UObject {
                 ^
transliterator.cpp:81:3: error: unknown type name 'Transliterator'; did you mean 'UTransliterator'?
  Transliterator *trans;
  ^~~~~~~~~~~~~~
  UTransliterator
/usr/local/include/unicode/utrans.h:70:15: note: 'UTransliterator' declared here
typedef void* UTransliterator;
              ^
transliterator.cpp:86:3: error: unknown type name 'UnicodeString'; did you mean 'icu_61::UnicodeString'?
  UnicodeString *u_txt;
  ^~~~~~~~~~~~~
  icu_61::UnicodeString
/usr/local/include/unicode/unistr.h:286:20: note: 'icu_61::UnicodeString' declared here
class U_COMMON_API UnicodeString : public Replaceable
                   ^
transliterator.cpp:101:11: error: use of undeclared identifier 'Transliterator'; did you mean 'icu_61::Transliterator'?
  trans = Transliterator::createInstance(UnicodeString(id, id_len), UTRANS_FORWARD, p_error, status);
          ^~~~~~~~~~~~~~
          icu_61::Transliterator
/usr/local/include/unicode/translit.h:243:18: note: 'icu_61::Transliterator' declared here
class U_I18N_API Transliterator : public UObject {
                 ^
transliterator.cpp:101:42: error: use of undeclared identifier 'UnicodeString'
  trans = Transliterator::createInstance(UnicodeString(id, id_len), UTRANS_FORWARD, p_error, status);
                                         ^
transliterator.cpp:106:15: error: unknown type name 'UnicodeString'; did you mean 'icu_61::UnicodeString'?
  u_txt = new UnicodeString(txt, txt_len);
              ^~~~~~~~~~~~~
              icu_61::UnicodeString
/usr/local/include/unicode/unistr.h:286:20: note: 'icu_61::UnicodeString' declared here
class U_COMMON_API UnicodeString : public Replaceable
                   ^
transliterator.cpp:107:8: error: member reference base type 'UTransliterator' (aka 'void *') is not a structure or union
  trans->transliterate(*u_txt);
  ~~~~~^ ~~~~~~~~~~~~~
transliterator.cpp:108:3: error: no template named 'StringByteSink'; did you mean 'icu_61::StringByteSink'?
  StringByteSink<std::string> sink(&result);
  ^~~~~~~~~~~~~~
  icu_61::StringByteSink
/usr/local/include/unicode/bytestream.h:232:7: note: 'icu_61::StringByteSink' declared here
class StringByteSink : public ByteSink {
      ^
transliterator.cpp:106:34: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
  u_txt = new UnicodeString(txt, txt_len);
              ~~~~~~~~~~~~~      ^~~~~~~
1 warning and 9 errors generated.
make: *** [transliterator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/opt/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/charlock_holmes-0.7.5 for inspection.
Results logged to /usr/local/opt/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/charlock_holmes-0.7.5/gem_make.out
dsh1705 commented 6 years ago

try adding this:

--with-cppflags=-DU_USING_ICU_NAMESPACE=1

referenced from: https://github.com/Homebrew/homebrew-php/pull/4829/commits/d7a3e0b6487780e0d983b35b8f42aad0fd01bf78

parkr commented 6 years ago

0.7.6 has been released with https://github.com/brianmario/charlock_holmes/pull/127 included.

ikappas commented 6 years ago

@dsh1705 Thank you very much for the workaround!

I managed to install 0.7.5 with --with-cppflags=-DU_USING_ICU_NAMESPACE=1