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

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

Closed
astudnev opened this issue Mar 12, 2017 · 5 comments

Comments

@astudnev
Copy link

astudnev commented Mar 12, 2017

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
Copy link

Look at the temporary decision. I'm using clang instead of [email protected]

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
Copy link
Author

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

@rssdev10
Copy link

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
Copy link

mrkn commented Mar 31, 2017

Use clang and clang++ on OSX.

@translunar
Copy link
Member

Duplicates #591; closing.

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

No branches or pull requests

4 participants