rmagick: fatal error: 'cstdbool' file not found
Description
I am trying to install rmagick on an M2 mac, but it fails during building.
Steps to Reproduce
% gem install gruff
Building native extensions. This could take a while...
ERROR: Error installing gruff:
ERROR: Failed to build gem native extension.
current directory: /Users/uwe/.gem/ruby/3.3.5/gems/rmagick-6.0.1/ext/RMagick
/Users/uwe/.rubies/ruby-3.3.5/bin/ruby extconf.rb
checking for brew... yes
checking for Ruby version >= 3.0.0... yes
checking for outdated ImageMagick version (<= 6.8.9)... no
checking for clang++... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include=${opt-dir}/include
--without-opt-include
--with-opt-lib=${opt-dir}/lib
--without-opt-lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/uwe/.rubies/ruby-3.3.5/bin/$(RUBY_BASE_NAME)
--with-pkg-config
--without-pkg-config
--with-override-variables
--without-override-variables
/Users/uwe/.rubies/ruby-3.3.5/lib/ruby/3.3.0/mkmf.rb:480:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/uwe/.rubies/ruby-3.3.5/lib/ruby/3.3.0/mkmf.rb:573:in `try_link0'
from /Users/uwe/.rubies/ruby-3.3.5/lib/ruby/3.3.0/mkmf.rb:591:in `try_link'
from extconf.rb:126:in `configure_compile_options'
from extconf.rb:48:in `initialize'
from extconf.rb:438:in `new'
from extconf.rb:438:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/uwe/.gem/ruby/3.3.5/extensions/arm64-darwin-23/3.3.0-static/rmagick-6.0.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/uwe/.gem/ruby/3.3.5/gems/rmagick-6.0.1 for inspection.
Results logged to /Users/uwe/.gem/ruby/3.3.5/extensions/arm64-darwin-23/3.3.0-static/rmagick-6.0.1/gem_make.out
uwe@MacBook-Pro sports % ;2B
mkmf.log:
find_executable: checking for brew... -------------------- yes
--------------------
assert_minimum_ruby_version!: checking for Ruby version >= 3.0.0... -------------------- yes
--------------------
assert_has_dev_libs!: checking for outdated ImageMagick version (<= 6.8.9)... -------------------- no
Detected ImageMagick version: 7.1.1
--------------------
find_executable: checking for clang++... -------------------- yes
--------------------
DYLD_LIBRARY_PATH=.:/Users/uwe/.rubies/ruby-3.3.5/lib "clang -o conftest -I/Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/arm64-darwin23 -I/Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby/backward -I/Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0 -I. -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/gdbm/include -I/opt/homebrew/opt/node@20/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -x c++ -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32 -I/opt/homebrew/Cellar/imagemagick/7.1.1-39/include/ImageMagick-7 -x c++ -std=c++11 -Wno-register -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -pipe conftest.c -L. -L/Users/uwe/.rubies/ruby-3.3.5/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib -L. -L/opt/homebrew/opt/node@20/lib -fstack-protector-strong -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib -L/opt/homebrew/opt/node@20/lib -L/opt/homebrew/Cellar/imagemagick/7.1.1-39/lib -lMagickCore-7.Q16HDRI -Wl,-rpath,/opt/homebrew/Cellar/imagemagick/7.1.1-39/lib -arch arm64 -L/opt/homebrew/Cellar/imagemagick/7.1.1-39/lib -lMagickCore-7.Q16HDRI -lruby.3.3-static -framework CoreFoundation -ldl -lobjc -lpthread -lpthread "
In file included from conftest.c:1:
In file included from /Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby.h:38:
In file included from /Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby/ruby.h:25:
In file included from /Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby/defines.h:74:
In file included from /Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby/backward/2/bool.h:22:
/Users/uwe/.rubies/ruby-3.3.5/include/ruby-3.3.0/ruby/internal/stdbool.h:31:12: fatal error: 'cstdbool' file not found
31 | # include <cstdbool>
| ^~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
System Configuration
- ImageMagick version: 7.1.1
- RMagick version: 6.0.1
- Ruby version: 3.3.5
- Environment (Operating system, version and so on): macOS Sonoma 14.7 (23H124)
- Additional information:
I see there are some issues in the tracker, but I could not find a solution. I have tried adding export CPPFLAGS="-x c++ " before installing rmagick.
Thank you for all your efforts developing rmagick 😄
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (8 by maintainers)
Confirming that installing Xcode, not just the developer tools, and reinstalling Ruby solves the issue.
However, I’m wondering what has changed - was Xcode installed by default in a previous version of macOS, or have they modified something in the developer tools that now causes this issue?
Thanks. Your logs are certainly wrong.
If your environments are set up properly, it should have following as expected:
I think the compiler is not recognized correctly because you set up Xcode after installing Ruby, or wrong environment variable was set.
https://github.com/rmagick/rmagick/blob/107265ae0f3dbc3e8f6dfbb9c205ec76ca717174/ext/RMagick/extconf.rb#L230
Can you check what
RbConfig::CONFIG['CXX']and ENV[‘CXX’] have value?If the value of RbConfig::CONFIG[‘CXX’] is different, I recommend strongly what you reinstall Ruby.
(Maybe, I think you can install when use CXX environment variable, like
CXX=clang++ gem install rmagick)I’m having the same issue, but I’m on an Intel Mac.
We use
asdffor Ruby version management, and this issue started for me when upgrading to Ruby 3.3.6.The initially error occurred when running
bundleon our Rails project after the Ruby upgrade. I noticed that there was an update for Apple’s developer command line tools, so I installed that, and also installed actual Xcode like @kapso above.At one point I had the following error
But then double checked that my ImageMagick install was still working and saw that
convertwas not in my path. I think this is likely because I attempted to run./before_install_osx.shin the rmagick repo to see what would happen. I reinstalledImageMagickfrom homebrew and then was back to the errors below:Output from bundle
gem_make.out
Edit: Forgot to say I’m on MacOS 14.7.1
What other information would be useful in debugging?
Thanks, Joe