error occurred while installing semacode (0.7.5) gem

564 views Asked by At

Issue while installing semacode gem from gemfile. is there a way to resolve this? i am running bundle install. Is this a issue with my machine or a gem issue? This issue did happen for the first time on my machine when i tried to run the application locally.

Using semacode 0.7.5 from https://github.com/toretore/semacode.git (at master@4e31e0b)

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



make "DESTDIR=" clean

.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/semacode-4e31e0b79a1a/ext
make "DESTDIR="
compiling reedsol.c
compiling semacode.c
semacode.c:61:3: error: implicit declaration of function 'iec16022init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  iec16022init(&semacode->width, &semacode->height, message);
  ^
semacode.c:96:28: warning: 'bzero' call operates on objects of type 'semacode_t' (aka 'struct semacode_t') while the size is based on a different type 'semacode_t *' (aka 'struct
semacode_t *') [-Wsizeof-pointer-memaccess]
    bzero(semacode, sizeof(semacode));
          ~~~~~~~~         ^~~~~~~~
semacode.c:96:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
    bzero(semacode, sizeof(semacode));
                           ^~~~~~~~
semacode.c:129:27: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  encode_string(semacode, StringValueLen(message), StringValuePtr(message));
  ~~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~

     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semacode.c:129:27: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  encode_string(semacode, StringValueLen(message), StringValuePtr(message));
  ~~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-2.3.0/ruby/ruby.h:995:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
semacode.c:239:20: warning: equality comparison result unused [-Wunused-comparison]
    semacode->data == NULL;
    ~~~~~~~~~~~~~~~^~~~~~~
semacode.c:239:20: note: use '=' to turn this equality comparison into an assignment
    semacode->data == NULL;
                   ^~
                   =
semacode.c:243:44: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  DATA_PTR(self) = encode_string(semacode, StringValueLen(message), StringValuePtr(message));
                   ~~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:990:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semacode.c:243:44: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  DATA_PTR(self) = encode_string(semacode, StringValueLen(message), StringValuePtr(message));
                   ~~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:995:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
6 warnings and 1 error generated.
make: *** [semacode.o] Error 1

make failed, exit code 2

Gem files will remain installed in .rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/semacode-4e31e0b79a1a for inspection.
Results logged to .rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/extensions/x86_64-darwin-19/2.3.0-static/semacode-4e31e0b79a1a/gem_make.out

An error occurred while installing semacode (0.7.5), and Bundler cannot continue.

In Gemfile:
  semacode
2

There are 2 answers

1
Huy Vo On BEST ANSWER

Try this

gem install semacode -v 0.7.5 -- --with-cflags="-Wno-error=implicit-function-declaration"

Here is more information:

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes

0
s.matty On

I've seen some similar issues on macOS that have only started since v12 was released. If you have v12 you can try downgrading to v11.5 from download.developer.apple.com/Developer_Tools/… and retrying the gem installation

credits - @anothermh