SciRuby / nmatrix

Dense and sparse linear algebra library for Ruby via SciRuby
Other
469 stars 133 forks source link

Error installing on MacOS: unrecognized command line option '-Wdivision-by-zero' on Mac #584

Closed astudnev closed 7 years ago

astudnev commented 7 years ago

Sorry, but the issue 426 still exists. I fail to install nmatrix on MacOS

gem install nmatrix

fails with error:

compiling nmatrix.cpp g++-4.9: error: unrecognized command line option '-Wdivision-by-zero' g++-4.9: error: unrecognized command line option '-Wextra-tokens' make: *** [nmatrix.o] Error 1

configuration:

ruby -v -rrbconfig -e 'puts RbConfig::MAKEFILE_CONFIG["CXX"]' ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16] g++

Full log:

gem install nmatrix
Building native extensions.  This could take a while...
ERROR:  Error installing nmatrix:
        ERROR: Failed to build gem native extension.
current directory: /Users/studnev/.rvm/gems/ruby-2.3.3/gems/nmatrix-0.2.3/ext/nmatrix
/Users/studnev/.rvm/rubies/ruby-2.3.3/bin/ruby -r ./siteconf20170312-93627-1qhob9w.rb extconf.rb
checking for apparent GNU g++ binary with C++0x/C++11 support... 4.9
using C++ standard... c++11
g++ reports version... gcc49
checking for rb_array_const_ptr() in ruby.h... yes
checking for FIX_CONST_VALUE_PTR in ruby.h... yes
checking for RARRAY_CONST_PTR in ruby.h... yes
checking for RARRAY_AREF in ruby.h... yes
creating nmatrix_config.h
creating Makefile

current directory: /Users/studnev/.rvm/gems/ruby-2.3.3/gems/nmatrix-0.2.3/ext/nmatrix
make "DESTDIR=" clean

current directory: /Users/studnev/.rvm/gems/ruby-2.3.3/gems/nmatrix-0.2.3/ext/nmatrix
make "DESTDIR="
compiling nmatrix.cpp
g++-4.9: error: unrecognized command line option '-Wdivision-by-zero'
g++-4.9: error: unrecognized command line option '-Wextra-tokens'
make: *** [nmatrix.o] Error 1

make failed, exit code 2
rssdev10 commented 7 years ago

Look at the temporary decision. I'm using clang instead of gcc@4.9

diff --git a/lib/nmatrix/mkmf.rb b/lib/nmatrix/mkmf.rb
index 544e3af..6a58341 100644
--- a/lib/nmatrix/mkmf.rb
+++ b/lib/nmatrix/mkmf.rb
@@ -38,6 +38,11 @@ def find_newer_gplusplus #:nodoc:
     puts ver
     return CONFIG['CXX']
   end
+
+  gpp = 'g++'
+  if (result = `which #{gpp}`)
+    return (CONFIG['CXX'] = gpp)
+  end
   false
 end
astudnev commented 7 years ago

@rssdev10 , it did not help, it finds the same g++ ( 4.9 )

rssdev10 commented 7 years ago

yes, you are right. Actually I removed gcc 4.9. Right now I have gcc without version which is identified as

gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)

You can remove a code before my patch if need to save gcc 4.9. In any case this method must be rewritten.

mrkn commented 7 years ago

Use clang and clang++ on OSX.

translunar commented 7 years ago

Duplicates #591; closing.