'Cannot Install gem stackprof on ruby 2.4.10 on Macbook M1

I am trying to bundle install my application. I have the gem stackprof and i keep getting this error whenever i try to install this gem.

I am using M1 with Ruby 2.4.10 and cant find any way around this. Has anyone had this issue and how did you solve it?

Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
    This could take a while...
    ERROR:  Error installing stackprof:
        ERROR: Failed to build gem native extension.
    
        current directory: /Users/tech/.rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/gems/stackprof-0.2.16/ext/stackprof
    /Users/tech/.rbenv/versions/2.4.10/bin/ruby -r ./siteconf20220514-21699-1433so.rb extconf.rb --with-cflags=-Wno-error=implicit-function-declaration
    checking for rb_postponed_job_register_one()... no
    *** 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
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/tech/.rbenv/versions/2.4.10/bin/$(RUBY_BASE_NAME)
    extconf.rb:8:in `<main>': missing API: are you using ruby 2.1+? (RuntimeError)
    
    To see why this extension failed to compile, please check the mkmf.log which can be found here:
    
      /Users/tech/.rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/extensions/-darwin-21/2.4.0/stackprof-0.2.16/mkmf.log
    
    extconf failed, exit code 1


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source