Libsass: Node-gyp g++ and libsass error

Created on 14 Apr 2016  ·  21Comments  ·  Source: sass/libsass

I've been following the guide to install Zurb foundation but running into a consistent issue.
$ npm install foundation-cli --global
is successful but
:foundation fivedoor$ foundation new
brings up:

g++: error: unrecognized command line option '-stdlib=libc++'
make: *** [Release/obj.target/libsass/src/libsass/src/ast.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/fivedoor/Documents/development/zurb/foundation/test130416-2/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 10.8.0
gyp ERR! command "/usr/local/bin/node" "/Users/fivedoor/Documents/development/zurb/foundation/test130416-2/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/fivedoor/Documents/development/zurb/foundation/test130416-2/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v4.4.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
Build failed

I was advised on the node-gyp issue forum that his was not a node-gyp bug but perhaps a libsass issue. I have seen similar errors in other github posts.

To be honest, being pretty new to node, I'm sure it's possible I may have been inept in implementing some of the various solutions suggested.

I have tried quite a few things without any joy:

  • complete uninstall/ reinstall latest node & npm;
  • clean npm cache; install with nvm, brew;
  • updating git to latest version that supports snow leopard;
  • npm --optional install ;
  • installed macports and then updated GCC and G++;
  • deleting .node-gyp folder and reinstall;
  • uninstall and reinstall foundation-cli.

Been keeping an expanding troubleshooting log as I go. The most recent stuff at https://github.com/fivedoor/foundation-records/blob/master/my_installation_log_post_reinstall100416

Failing a silver bullet solution, could someone advise if upgrading to a later OS is likely to help or not? ( I know snow leopard is old but I've clung on to it for stability.) I did get some warnings from brew that " We (and Apple) do not provide support for OS 10.6"

The frustrating thing is at this stage I'm not trying to do anything more 'advanced' than just install the packages I need to get started.

  • MACOS X Version 10.6.8
  • npm 3.8.6
  • node v4.4.2
  • Xcode 3.2.6
  • GCC 4.8.5
  • g++ 4.8.5
  • nvm 0.31.0
  • git version 1.8.4.2
  • curl 7.19.7

thanks

Most helpful comment

Just to update the post with what got me through in the end...
I tried
brew install --with-clang llvm
butclang --versionstill returned version 1.7

I then tried the following:

$ port search clang
$ sudo port install clang-3.6
$ port select --list clang
$ sudo port select --set clang mp-clang-3.6

That seemed to do it as
$ clang --version returned clang version 3.6.2 (tags/RELEASE_362/final)

I then updated the paths:

$ export CC=/opt/local/bin/clang
$ export CXX=/opt/local/bin/clang++

This time the installation completed successfully :)

Thank you very much for your help and guiding me in the right direction saper - it was invaluable!

One postscript -
I did seem to get an lot of warnings during the install.
https://github.com/fivedoor/foundation-records/blob/master/installation_log_190416

I've had quite a few warnings from brew about the support for 10.6.8. and before the above worked was on the verge of giving up and installing a version of el capitan (to run as partitioned drive so I can retain snow leopard for other apps)

I wonder if that's still a wiser option going forward as I get the feeling I may run into more issues related to using snow leopard/ an older os?

Anyway thanks again for the support on this issue!

All 21 comments

This actually belongs to https://github.com/sass/node-sass/issues , but let me ask you first: what happens if you use clang instead of gcc?

Thanks for your input saper.

This is all pretty new territory to me so I may need to do a little bit of research into switching the compiler.

It looks like from Xcode 4.2, Clang is the default compiler for Mac OS X.

I am using Xcode 3.2.6 which was the most up to date version I could download for snow leopard.
From running 'clang --version' I see I have clang version 1.7 installed.

From a quick search it looks like I can effect the change with:
option(USE_CLANG "build application with clang" ON)

But I think I will need to have proper read at http://clang.llvm.org/get_started.html and test tonight and then I can feedback.

Thanks again!

Closing to keep the issue tracker tidy, since this should go downstream to node-sass.
@fivedoor Feel free to report your findings here anyway if you can get clang working.

Revisiting to report I tried the switch to clang and still hit pretty much the same errors.

Except this time instead of the line:
g++: error: unrecognized command line option '-stdlib=libc++'
I got
make: clang++: No such file or directory

which perhaps suggest the commands I used to switch to clang were not sufficient:

fivedoors-MacBook-Pro:~ fivedoor$ export CC=clang
fivedoors-MacBook-Pro:~ fivedoor$ export CXX=clang++

The install process has been very slow and this time was the worst. It took about 3.5 hrs for the install to run it's course (and fail).

I will see what input I can get re the error on the node-sass forum and report a solution if I get one.

@fivedoor make: clang++: No such file or directory is not that bad, the commandline invocation could not find your compiler - can you try to find out what is the full path to clang and clang++ and use it instead? export CC=/full/path/to/clang export CXX=/full/path/to/clang++

Thanks saper

So I tried:
fivedoors-MacBook-Pro:~ fivedoor$ export CC=/usr/bin/clang
fivedoors-MacBook-Pro:~ fivedoor$ export CXX=/usr/bin/clang++

which resulted in the same error again but with the distinction:
make: /usr/bin/clang++: No such file or directory

Checking again:
$ which clang
returns:
/usr/bin/clang

but
which clang++
does not return anything

From initial search I'd assumed that having clang I would also mean clang++ was available?
Everything I can find re installing clang++ is geared towards ubuntu.
Do you have a further recommendation on what to try next?
Thanks!

Just try export CXX=/usr/bin/clang Can you double check /usr/bin/clang --version to make sure you are using your new clang installed and not the oldish one from Apple?

/usr/bin/clang --version
retrurns:

Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
Thread model: posix

yes, looks like that is the version that came with 10.6.8 I think

I did try export CXX=/usr/bin/clang before getting the previous error messages
thanks

Looks like I can use brew to install a later version with
brew install --with-clang llvm
I will take a look into giving that a go

Perfect!

Just to update the post with what got me through in the end...
I tried
brew install --with-clang llvm
butclang --versionstill returned version 1.7

I then tried the following:

$ port search clang
$ sudo port install clang-3.6
$ port select --list clang
$ sudo port select --set clang mp-clang-3.6

That seemed to do it as
$ clang --version returned clang version 3.6.2 (tags/RELEASE_362/final)

I then updated the paths:

$ export CC=/opt/local/bin/clang
$ export CXX=/opt/local/bin/clang++

This time the installation completed successfully :)

Thank you very much for your help and guiding me in the right direction saper - it was invaluable!

One postscript -
I did seem to get an lot of warnings during the install.
https://github.com/fivedoor/foundation-records/blob/master/installation_log_190416

I've had quite a few warnings from brew about the support for 10.6.8. and before the above worked was on the verge of giving up and installing a version of el capitan (to run as partitioned drive so I can retain snow leopard for other apps)

I wonder if that's still a wiser option going forward as I get the feeling I may run into more issues related to using snow leopard/ an older os?

Anyway thanks again for the support on this issue!

typeid warning is harmless, it got fixed later - see https://github.com/sass/libsass/issues/1523

configure: error: installation or configuration problem: assembler cannot create object files.

This is something more serious, you might want to report this to the people maintaining jpeg-tran.

Most probably you need to point somehow to the assembler which works; something strange is going on here.

Just install development dependencies and try to run npm test against node-sass, I hope it works!

@fivedoor I am going through the exact same problem. trying to switch the compiler to clang. Can you please tell me the steps on how to do it. Thank you!

Also tried to install later version of clang using
brew install --with-clang llvm

but i am getting the below error. I am a novice and really need help!

shyam-molugus-macbook-5:pulses Shyam$ brew install --with-clang llvm
Warning: You are using OS X 10.6.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
==> Downloading http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz
Already downloaded: /Users/Shyam/Library/Caches/Homebrew/llvm-3.6.2.tar.xz
==> Downloading http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz
Already downloaded: /Users/Shyam/Library/Caches/Homebrew/llvm--clang-3.6.2.tar.xz
==> cmake -G Unix Makefiles /private/tmp/llvm-20160602-48463-1r6cqk/llvm-3.6.2.src
Last 15 lines from /Users/Shyam/Library/Logs/Homebrew/llvm/01.cmake:

make: *** [cmTC_183c8/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:25 (project)

-- Configuring incomplete, errors occurred!
See also "/tmp/llvm-20160602-48463-l64qtc/CMakeFiles/CMakeOutput.log".
See also "/tmp/llvm-20160602-48463-l64qtc/CMakeFiles/CMakeError.log".

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
https://github.com/Homebrew/homebrew-core/issues

These open issues may also help:
llvm 3.8.0 https://github.com/Homebrew/homebrew-core/pull/1593
llvm and openmp https://github.com/Homebrew/homebrew-core/issues/1254

@smolugu well, ths completely unrelated to this project. You are pretty much on your own, since the messages say your OS version is not supported. You can try asking in the brew community for help. Upgrading your cmake may help, maybe.

@saper Thank you! I was hoping to get help here since @fivedoor was having the same issue and using the same OS X. Will try again after upgrading cmake.

@smologu
Just recapping the core stuff from the notes I made on what I did.
It has been a while so hope it's clear & helps :

// Follow advice on https://github.com/nodejs/node-gyp/issues/906
// install gcc48

$ sudo port install gcc48
$ sudo port select --set gcc mp-gcc48
Selecting 'mp-gcc48' for 'gcc' succeeded. 'mp-gcc48' is now active.

// delete node-gyp folder again

$ which clang
/usr/bin/clang

// confirm path available

$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

// find what is the full path to clang and clang++ and use it instead
// https://github.com/sass/libsass/issues/1998#issuecomment-211099908

// check available versions of clang
$ port search clang

//and install
$ sudo port install clang-3.6

// seemed to work so check

$ port select --list clang

Available versions for clang:
    mp-clang-3.6
    none (active)

// looks good so select 3.6

$ sudo port select --set clang mp-clang-3.6

Password:
Selecting 'mp-clang-3.6' for 'clang' succeeded. 'mp-clang-3.6' is now active.

// Success
//check updated - success

//try to set export location

$ export CC=/opt/local/bin/clang
$ export CXX=/opt/local/bin/clang++

// Success

Think you @fivedoor , that's very useful. clang 3.6 is too new to be built with an old clang, so we need to take an immediate step - first to build gcc48 and then use it build clang-3.6.

Actually gcc48 should be enough to build node-sass, but then you are using a modern libstdc++ which comes with gcc48 and you may end up in trouble when running our code from within node, which AFAIK uses the old C++ library still provided by Apple.

@fivedoor @saper Thank you! Really appreciate it. I almost gave up and thinking of buying a new mac. but will try your suggestions. will update you.

Regards,

Looks like Richard Stallman has won against Apple this time :)

I've had success with the following on 10.6.8.

brew install gcc
CXX=gcc-5 brew install libsass

But CXX=gcc-5 npm install node-sass fails with a flag error. I see that the node-sass node-gyp file adds c++11 flags for clang, which conflict with the c++ flags for gcc. It would be nice if node-sass could detect whether older macs are actually running clang, or document how to override the flags.

I have yet to successfully brew clang using gcc-5, which takes forever on an old laptop. I mention this as a contrast to using port.

It’s probably worth adding that while I was able to resolve the original issue in this post I did run into more problems down the line which seemed to be related to running an older OS.

I eventually installed el-capitan on an external drive, preserving 10.6.8 to run some older software and as a fall back. As long as you have a machine running snow leopard or above I believe you should be able to update to the latest OS for free on that machine.

// Compatibility check:
http://www.everymac.com/mac-answers/os-x-el-capitan-faq/os-x-el-capitan-compatible-macs-system-requirements.html

That might seem like a long winded work-around but using an up to date OS everything runs quicker and I come up against a lot less conflicts that need resolving so it might save time in the long run provided you don't have a specific need to stay running snow leopard.

Was this page helpful?
0 / 5 - 0 ratings