sassc-ruby icon indicating copy to clipboard operation
sassc-ruby copied to clipboard

error: fmod is not a member of std

Open dima4p opened this issue 4 years ago • 13 comments

Hello, while installing the gem I've got the problem to compile the extension.

$ gem install sassc -v '2.2.0' --source 'https://rubygems.org/'                     Building native extensions. This could take a while...
ERROR:  Error installing sassc:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-2.6.3@my_project/gems/sassc-2.2.0/ext
/usr/local/rvm/rubies/ruby-2.6.3/bin/ruby -I /usr/local/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0 -r ./siteconf20190828-18319-ou8ovf.rb extconf.rb
creating Makefile

current directory: /usr/local/rvm/gems/ruby-2.6.3@my_project/gems/sassc-2.2.0/ext
make "DESTDIR=" clean

current directory: /usr/local/rvm/gems/ruby-2.6.3@my_project/gems/sassc-2.2.0/ext
make "DESTDIR="
compiling ./libsass/src/color_maps.cpp
In file included from ./libsass/src/ast.hpp:19:0,
                 from ./libsass/src/color_maps.cpp:5:
./libsass/src/util.hpp: In function ‘T Sass::absmod(const T&, const T&)’:
./libsass/src/util.hpp:28:11: error: ‘fmod’ is not a member of ‘std’
     T m = std::fmod(n, r);
           ^
./libsass/src/util.hpp:28:11: note: suggested alternative:
In file included from /usr/include/features.h:368:0,
                 from /usr/include/c++/5.5.0/x86_64-slackware-linux/bits/os_defines.h:39,
                 from /usr/include/c++/5.5.0/x86_64-slackware-linux/bits/c++config.h:489,
                 from /usr/include/c++/5.5.0/string:38,
                 from ./libsass/src/sass.hpp:55,
                 from ./libsass/src/color_maps.cpp:3:
/usr/include/bits/mathcalls.h:187:1: note:   ‘fmod’
 __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
 ^
Makefile:235: recipe for target 'color_maps.o' failed
make: *** [color_maps.o] Error 1

My gcc is:

$ gcc -v
Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/5.5.0/lto-wrapper
Target: x86_64-slackware-linux
Configured with: ../gcc-5.5.0/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --with-python-dir=/lib64/python2.7/site-packages --enable-libstdcxx-dual-abi --with-default-libstdcxx-abi=gcc4-compatible --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --enable-lto --disable-install-libiberty --with-gnu-ld --verbose --enable-java-home --with-java-home=/usr/lib64/jvm/jre --with-jvm-root-dir=/usr/lib64/jvm --with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar=/home/slackware/slackbuilds/gcc-5.5.0/antlr-runtime-3.4.jar --enable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 5.5.0 (GCC) 

With the version 2.1.0 there is no problem

dima4p avatar Aug 28 '19 20:08 dima4p

Version 2.1.0 comes with a pre-compiled library for Linux+glibc but the new version doesn't.

This seems to be a bug (missing include) that's been fixed on libsass master but is not in any release yet. This missing include seems to only break some compiler versions.

glebm avatar Aug 28 '19 22:08 glebm

@glebm, so it seems to be easy fixable?

dima4p avatar Aug 29 '19 07:08 dima4p

Hey @glebm, thanks for identifying the problem! Is there any way to estimate when this fix will be included in a new release?

RaymondFallon avatar Sep 03 '19 13:09 RaymondFallon

@RaymondFallon, is not it easier to fix the line

./libsass/src/util.hpp:28:11

?

dima4p avatar Sep 03 '19 14:09 dima4p

Bellow code might help.

--- ext/libsass/src/util.hpp.orig	2019-09-16 15:47:08.475272400 +0000
+++ ext/libsass/src/util.hpp
@@ -9,6 +9,7 @@
 #include "ast_fwd_decl.hpp"
 
 #include <cstring>
+#include <cmath>
 #include <vector>
 #include <string>
 #include <assert.h>

taca avatar Sep 16 '19 15:09 taca

#153 is dupe of this. Someone maybe need to update the libsass submodule? So that cmath would be included as per @taca's suggestion?

vmiheer avatar Nov 07 '19 23:11 vmiheer

update the libsass submodule? see https://github.com/sass/sassc-ruby/pull/164

ahorek avatar Nov 07 '19 23:11 ahorek

@ahorek, yup that release has include. So potentially fix the issue.

vmiheer avatar Nov 07 '19 23:11 vmiheer

I built the gem with the modification and used as part of jekyll, things work without hitch.

vmiheer avatar Nov 08 '19 16:11 vmiheer

The problem for me was the version of GCC compiler. After I have upgraded it from 5.5.0 to 9.2.0 all is OK. Probably gem should check the version and report it at install.

dima4p avatar Nov 11 '19 16:11 dima4p

After upgrade of GCC from 5.5.0 to 8.3.0 the installation process successfully finished: Installing sassc 2.2.1 (was 2.1.0) with native extensions🛠 Upd. just brew unlink gcc

JuPlutonic avatar Nov 11 '19 19:11 JuPlutonic

Note: upgrading compiler isn't always solution e.g. linuxbrew uses gcc 5.5.

vmiheer avatar Nov 11 '19 21:11 vmiheer

brew uninstall --ignore-dependencies gcc solved it for me.

Be aware that you should know what you are doing and have replacements available. Like sudo apt-get install ruby-full build-essential zlib1g-dev or something similar. Else the other apps brew installed might stop working for you.

rscircus avatar Jan 21 '20 11:01 rscircus