hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports
http://rubygems.org/gems/serialport
GNU General Public License v2.0
246 stars 58 forks source link

Installing serialport Gem in Ruby 3.0.0 #69

Open ninp0 opened 3 years ago

ninp0 commented 3 years ago

Greetings,

In order to install the serialport gem using Ruby 3.0.0 on MacOS Big Sur (11.1) the following is required:

$ gem install serialport -- --with-cflags=-Wno-implicit-function-declaration

In order to install the serialport gem using Ruby 3.0.0 on MacOS Big Sur (11.1) the following is required when using bundler:

$ bundle config build.serialport --with-cflags=-Wno-implicit-function-declaration
$ bundle install

Is there a fix to address the issue? Simply executing:

$ gem install serialport

generates the following error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-3.0.0@global/gems/serialport-1.3.1/ext/native
/usr/local/rvm/rubies/ruby-3.0.0/bin/ruby -I /usr/local/rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0 -r
./siteconf20210107-73355-9t3pde.rb extconf.rb
checking for OS... darwin
checking for termios.h... yes
checking for unistd.h... yes
creating Makefile

current directory: /usr/local/rvm/gems/ruby-3.0.0@global/gems/serialport-1.3.1/ext/native
make DESTDIR\= clean

current directory: /usr/local/rvm/gems/ruby-3.0.0@global/gems/serialport-1.3.1/ext/native
make DESTDIR\=
compiling posix_serialport_impl.c
posix_serialport_impl.c:113:4: error: implicit declaration of function 'rb_secure' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
   rb_secure(4);
   ^
posix_serialport_impl.c:114:13: warning: incompatible pointer to integer conversion passing 'struct RFile *' to
parameter of type 'VALUE' (aka 'unsigned long') [-Wint-conversion]
   OBJSETUP(sp, class, T_FILE);
            ^~
/usr/local/rvm/rubies/ruby-3.0.0/include/ruby-3.0.0/ruby/internal/newobj.h:43:26: note: passing argument to parameter
'obj' here
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
                         ^
1 warning and 1 error generated.
make: *** [posix_serialport_impl.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/rvm/gems/ruby-3.0.0@global/gems/serialport-1.3.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-3.0.0@global/extensions/x86_64-darwin-20/3.0.0/serialport-1.3.1/gem_make.out

Please provide guidance around addressing this at your earliest convenience. Thanks!