Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error using GCC version 14 (Arch GNU/Linux) #173

Closed
kktlnx opened this issue May 23, 2024 · 6 comments · Fixed by #174
Closed

Build error using GCC version 14 (Arch GNU/Linux) #173

kktlnx opened this issue May 23, 2024 · 6 comments · Fixed by #174

Comments

@kktlnx
Copy link

kktlnx commented May 23, 2024

I'm not certain if the error is directly related to the compiler itself (I'm using Arch GNU/Linux with gcc/g++ 14.1.1) as I've noticed a new issue with the ICU version mentioned (#172). The logs are as follows:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/charlock_holmes-0.7.7/ext/charlock_holmes
/home/user/.asdf/installs/ruby/2.7.8/bin/ruby -I /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/2.7.0 -r ./siteconf20240522-106487-1tjcca2.rb extconf.rb
checking for -licui18n... yes
checking for unicode/ucnv.h... yes
checking for -lz... yes
checking for -licuuc... yes
checking for -licudata... yes
creating Makefile

current directory: /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/charlock_holmes-0.7.7/ext/charlock_holmes
make "DESTDIR=" clean

current directory: /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/charlock_holmes-0.7.7/ext/charlock_holmes
make "DESTDIR="
compiling converter.c
compiling encoding_detector.c
compiling ext.c
compiling transliterator.cpp
In file included from /usr/include/unicode/unistr.h:39,
                 from /usr/include/unicode/translit.h:27,
                 from transliterator.cpp:5:
/usr/include/unicode/stringpiece.h:133:29: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
  133 |             typename = std::enable_if_t<
      |                             ^~~~~~~~~~~
/usr/include/unicode/stringpiece.h:133:24: note: ‘std::enable_if_t’ is only available from C++14 onwards
  133 |             typename = std::enable_if_t<
      |                        ^~~
/usr/include/unicode/stringpiece.h:133:40: error: expected ‘>’ before ‘<’ token
  133 |             typename = std::enable_if_t<
      |                                        ^
In file included from /usr/include/unicode/uenum.h:25,
                 from /usr/include/unicode/utrans.h:22,
                 from /usr/include/unicode/translit.h:29:
/usr/include/unicode/localpointer.h:561:26: error: parameter declared ‘auto’
  561 | template <typename Type, auto closeFunction>
      |                          ^~~~
/usr/include/unicode/localpointer.h:573:76: error: template argument 2 is invalid
  573 |     explicit LocalOpenPointer(std::unique_ptr<Type, decltype(closeFunction)> &&p)
      |                                                                            ^
/usr/include/unicode/localpointer.h:583:78: error: template argument 2 is invalid
  583 |     LocalOpenPointer &operator=(std::unique_ptr<Type, decltype(closeFunction)> &&p) {
      |                                                                              ^
/usr/include/unicode/localpointer.h:599:59: error: template argument 2 is invalid
  599 |     operator std::unique_ptr<Type, decltype(closeFunction)> () && {
      |                                                           ^
/usr/include/unicode/uenum.h:69:1: note: invalid template non-type parameter
   69 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/unicode/uset.h:358:1: note: invalid template non-type parameter
  358 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/unicode/utrans.h:258:1: note: invalid template non-type parameter
  258 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUTransliteratorPointer, UTransliterator, utrans_close);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:238: transliterator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/charlock_holmes-0.7.7 for inspection.
Results logged to /home/user/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/charlock_holmes-0.7.7/gem_make.out

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

In Gemfile:
  charlock_holmes

To fix this, I changed the 37th line in the extconf.rb file from

$CXXFLAGS << ' -std=c++11'

to

$CXXFLAGS << ' -std=c++17'

and then build again.
Here are steps:

gem fetch charlock_holmes -v '0.7.7'
gem spec charlock_holmes-0.7.7.gem --ruby > charlock.spec
gem unpack charlock_holmes-0.7.7.gem
mv charlock.spec charlock_holmes-0.7.7/
cd charlock_holmes-0.7.7

# now change code
# emacs -nw  file / code .

gem build charlock.spec
gem install ./charlock_holmes-0.7.7.gem
@w-zygmuntowicz
Copy link

If it's helpful, I just checked that the changes don't cause compilation errors on an older system (GCC 13.2.1 and ICU 72.4)

@nerijunior
Copy link

Same here.

@raucao
Copy link

raucao commented Jun 4, 2024

Just ran into this, too. Tried the steps above, but the same error persists.

@kktlnx
Copy link
Author

kktlnx commented Jun 5, 2024

Just ran into this, too. Tried the steps above, but the same error persists.

Sorry to hear that, you can experiment with different flag settings too after a failed installation. A Makefile then appears in the directory and you can directly edit this file and compile with make until you get it right. In my distribution Also I have the option of installing the older gcc and use them as separate commands, you can then also use that commands in the Makefile.

@rnestler
Copy link
Contributor

rnestler commented Jun 5, 2024

Actually just removing the flag altogether works for me as well. This should be preferred IMO, since the standard flags on a system should be fine.

@rnestler
Copy link
Contributor

As a workaround one can also use gem install charlock_holmes -- --with-cxxflags='#' to comment out the following build flags 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants