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

Can't install HEAD #34

Closed
jpmckinney opened this issue Sep 10, 2012 · 16 comments
Closed

Can't install HEAD #34

jpmckinney opened this issue Sep 10, 2012 · 16 comments
Assignees

Comments

@jpmckinney
Copy link

Installing from git:

Using nmatrix (0.0.2) from https://github.com/SciRuby/nmatrix.git (at master) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/james/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for clapack_dgetrf() in -llapack... no
checking for clapack.h... yes
checking for cblas_dgemm() in -lcblas... yes
checking for ATL_dgemmNN() in -latlas... no
checking for cblas.h... yes
creating nmatrix_config.h
creating Makefile

make
compiling nmatrix.cpp
cc1plus: error: unrecognized command line option "-std=c++0x"
make: *** [nmatrix.o] Error 1

Gem files will remain installed in /Users/james/.rvm/gems/ruby-1.9.3-p194/bundler/gems/nmatrix-506812677faa for inspection.
Results logged to /Users/james/.rvm/gems/ruby-1.9.3-p194/bundler/gems/nmatrix-506812677faa/ext/nmatrix/gem_make.out

Downloading the git repository and running rake compile (with or without bundle exec) gives a similar error:

rake/gempackagetask is deprecated.  Use rubygems/package_task instead
mkdir -p tmp/x86_64-darwin11.4.0/nmatrix/1.9.3
cd tmp/x86_64-darwin11.4.0/nmatrix/1.9.3
/Users/james/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -I. ../../../../ext/nmatrix/extconf.rb
checking for clapack_dgetrf() in -llapack... no
checking for clapack.h... yes
checking for cblas_dgemm() in -lcblas... yes
checking for ATL_dgemmNN() in -latlas... no
checking for cblas.h... yes
creating nmatrix_config.h
creating Makefile
cd -
cd tmp/x86_64-darwin11.4.0/nmatrix/1.9.3
make
compiling ../../../../ext/nmatrix/nmatrix.cpp
cc1plus: error: unrecognized command line option "-std=c++0x"
make: *** [nmatrix.o] Error 1
rake aborted!
Command failed with status (2): [make...]

Tasks: TOP => compile => compile:x86_64-darwin11.4.0 => compile:nmatrix:x86_64-darwin11.4.0 => copy:nmatrix:x86_64-darwin11.4.0:1.9.3 => tmp/x86_64-darwin11.4.0/nmatrix/1.9.3/nmatrix.bundle
@jpmckinney
Copy link
Author

I want to install HEAD, because 0.0.1 conflicts with NArray.

@atimin
Copy link

atimin commented Sep 10, 2012

Perhaps you don't have a installed ATLAS packet or it has installed in no standard location. You can point its location for header files before installation. For example:

export C_INCLUDE_PATH=/usr/local/atlas/include
export CPLUS_INCLUDE_PATH=/usr/local/atlas/include

@jpmckinney
Copy link
Author

I'm on Mac OS X Lion 10.7.4 with Xcode 4.3.2, and I do:

export C_INCLUDE_PATH=/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/
export CPLUS_INCLUDE_PATH=/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/

The cc1plus: error: unrecognized command line option "-std=c++0x" is because my version of g++ doesn't recognize the -std=c++0x option. What version of g++ are you using? Mine is:

i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

@jpmckinney
Copy link
Author

Your requirements section says you need gcc 4.2, but c++0x is only in GCC 4.3 and later.

@atimin
Copy link

atimin commented Sep 10, 2012

Yes, our right! Needs gcc-4.3. But I'm not understand how you compiled it to report #35 issue?

@atimin
Copy link

atimin commented Sep 10, 2012

You can update gcc?

@jpmckinney
Copy link
Author

I'm currently compiling a more recent GCC using the command below:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb

I had previously upgraded from an earlier Xcode, so I saw messages like:

Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.

To fix that, I needed to run:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

@atimin
Copy link

atimin commented Sep 10, 2012

Sorry I'm not user of OSX and I know nothing about it. Currently NMatrix is developing on linux. If you have success and one minute you can add section about installation on OSX here https://github.com/flipback/nmatrix/wiki/NMatrix-Installation. It will be excellent :)

@jpmckinney
Copy link
Author

I started writing something here. With the new GCC, if I replace the CC and CXX in the Makefile that extconf.rb creates to point to the new gcc and g++ commands, I get:

g++-4.7: error: unrecognized command line option '-Wshorten-64-to-32'

If I remove that option, I get:

compiling ../../../../ext/nmatrix/nmatrix.cpp
../../../../ext/nmatrix/nmatrix.cpp: In function 'VALUE nm_factorize_lu_bang(VALUE)':
../../../../ext/nmatrix/nmatrix.cpp:948:7: error: 'clapack_cgetrf' was not declared in this scope
../../../../ext/nmatrix/nmatrix.cpp:948:23: error: 'clapack_zgetrf' was not declared in this scope
In file included from ../../../../ext/nmatrix/storage/storage.h:50:0,
                 from ../../../../ext/nmatrix/util/io.h:38,
                 from ../../../../ext/nmatrix/nmatrix.cpp:48:
../../../../ext/nmatrix/storage/yale.h: At global scope:
../../../../ext/nmatrix/storage/yale.h:104:18: warning: inline function 'size_t nm_yale_storage_get_size(const YALE_STORAGE*)' used but never defined [enabled by default]

If I set CC and CXX to clang and clang++, I get:

compiling ../../../../ext/nmatrix/nmatrix.cpp
In file included from ../../../../ext/nmatrix/nmatrix.cpp:46:
In file included from ../../../../ext/nmatrix/data/data.h:43:
../../../../ext/nmatrix/data/complex.h:35:10: fatal error: 'type_traits' file not found
#include <type_traits>
         ^

If I set CC and CXX to clang and clang++ in the extconf.rb file instead, I get:

compiling ../../../../ext/nmatrix/nmatrix.cpp
error: invalid value 'c++11' in '-std=c++11'

My clang version is:

Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)

I'll try upgrading to a version of clang that supports c++11.

@translunar
Copy link
Member

Hey, sorry for the delay. Aleksey just pointed this thread out to me.

Your brew-installed g++ should do the trick. It looks like the problem is that it can't find clapack.h. I see you already redirected CPLUS_INCLUDE_PATH to your cblas.h location. Do the functions it's looking for exist in that file, or do they have different names and arguments?

If different, there are a few things we can do in the code. Basically all of the LAPACK functions it would need have been implemented in C++, but it would prefer to use the ATLAS-clapack versions. It's a pretty easy fix, which I can work on later today if you'd be willing to test it.

@jpmckinney
Copy link
Author

I'm pretty sure it can find clapack.h:

checking for clapack.h... yes

How does extconf select the gcc and g++ binaries to use? It's always choosing gcc-4.2 and g++-4.2 for the Makefile. I need to change the extconf.rb file to make it use the correct binaries.

Here are gists of my clapack.h and cblas.h. In clapack.h, there is no clapack_cgetrf but there is a cgetrf_ (I'm not a C/C++ programmer).

I had the latest Xcode but not the latest Command-Line Tools. Added a note in the wiki about that. It doesn't fix the clang error above, though. My clang version is Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn).

@jpmckinney
Copy link
Author

Ok, so to recap:

If I use what's in git HEAD, extconf.rb creates a Makefile that uses gcc 4.2, which won't work, because the c++0x and c++11 extensions are not available in 4.2.

If I set CC and CXX in extconf.rb to be clang and clang++ (4.0), rm -rf tmp and rake compile, I get the type_traits.h error above. If I add -stdlib=libc++ to CXXFLAGS in the Makefile and run rake compile again (without rm -rf tmp), I get this gist of 20 errors.

If I set CC and CXX in extconf.rb to be gcc and g++ (4.7.1), rm -rf tmp and rake compile, I get the -Wshorten-64-to-32 error above. If I edit the Makefile to remove that option and run rake compile again (without rm -rf tmp), I get:

compiling ../../../../ext/nmatrix/nmatrix.cpp
In file included from ../../../../ext/nmatrix/nmatrix.cpp:40:0:
/usr/local/Cellar/gcc/4.7.1/gcc/include/c++/4.7.1/ext/algorithm:65:21: error: expected '{' before '_GLIBCXX_VISIBILITY'
/usr/local/Cellar/gcc/4.7.1/gcc/include/c++/4.7.1/ext/algorithm:65:40: error: expected constructor, destructor, or type conversion before '(' token
../../../../ext/nmatrix/nmatrix.cpp:1555:1: error: expected '}' at end of input
make: *** [nmatrix.o] Error 1

The Makefile command that causes the error is:

g++-4.7 -I. -I/Users/james/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin11.4.0 -I/Users/james/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/james/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I../../../../ext/nmatrix -DHAVE_CLAPACK_H -DHAVE_CBLAS_H -I/Users/james/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O0 -std=c++11 -fno-common -Wall -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -fno-common -pipe -O0 -o nmatrix.o -c ../../../../ext/nmatrix/nmatrix.cpp

The following minimal command has the same error:

g++-4.7 -I../../../../ext/nmatrix -std=c++11 -o nmatrix.o -c ../../../../ext/nmatrix/nmatrix.cpp 

These errors are new - I wasn't getting them before for the same commands.

@translunar
Copy link
Member

Okay. Yes, the problem is with clapack. I pushed a change which compiles on my Macbook Air (Snow Leopard). But on there, it wasn't finding clapack.h at all (even the version that you gisted, which is present).

I'd suggest you remove clapack.h from your include paths, if possible, but keep cblas.h. Alternatively, you can go into the compilation tmp directory and remove the line that says #define HAVE_CLAPACK_H.

Want to try that and let me know how it goes?

@jpmckinney
Copy link
Author

Hmm, how did you compile it? I get:

compiling ../../../../ext/nmatrix/util/math.cpp
../../../../ext/nmatrix/util/math.cpp:126:23: fatal error: clapack.h: No such file or directory

If I wrap the include line like:

#ifdef HAVE_CLAPACK_H
  #include <clapack.h>
#endif

It seems to work!

@translunar
Copy link
Member

Oops, you're right. Sorry, I forgot to commit that change.

Thanks for doing the write-up. Note that there is now also a script for installing GCC 4.7.1, in the scripts/ directory. You might mention that as well.

@alexspeller
Copy link

Anyone getting here via google, the wiki page has moved and been updated:

https://github.com/SciRuby/nmatrix/wiki/Installation

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

No branches or pull requests

4 participants