Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Error #35

Open
MadBomber opened this issue Apr 1, 2024 · 3 comments
Open

Compiler Error #35

MadBomber opened this issue Apr 1, 2024 · 3 comments

Comments

@MadBomber
Copy link

Attempting to gem ins ruby-fann with Ruby v3.3.0 with latest MacOS on an M2max chip. I'm seeing compiler errors on the extension.

 $ gem install ruby-fann
Building native extensions. This could take a while...
ERROR:  Error installing ruby-fann:
  ERROR: Failed to build gem native extension.

    current directory: /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-fann-2.0.2/ext/ruby_fann
/Users/dewayne/.rbenv/versions/3.3.0/bin/ruby extconf.rb
checking for doublefann.h... yes
creating Makefile

current directory: /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-fann-2.0.2/ext/ruby_fann
make DESTDIR\= sitearchdir\=./.gem.20240401-60867-cly9bi sitelibdir\=./.gem.20240401-60867-cly9bi clean

current directory: /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-fann-2.0.2/ext/ruby_fann
make DESTDIR\= sitearchdir\=./.gem.20240401-60867-cly9bi sitelibdir\=./.gem.20240401-60867-cly9bi
compiling ruby_fann.c
In file included from ruby_fann.c:3:
In file included from ./doublefann.h:31:
./fann.h:116:6: warning: '_MSC_VER' is not defined, evaluates to 0 [-Wundef]
#if (_MSC_VER > 1300)
     ^
In file included from ruby_fann.c:5:
./fann_augment.h:84:20: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                i, RARRAY_LEN(inputs_i)),
                   ^~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
In file included from ruby_fann.c:5:
./fann_augment.h:83:69: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
                "Number of inputs at [%d] is inconsistent: (%du != %d)",
                                                                   ~^
./fann_augment.h:93:20: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                i, RARRAY_LEN(outputs_i)),
                   ^~~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
In file included from ruby_fann.c:5:
./fann_augment.h:92:69: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
                "Number of outputs at [%d] is inconsistent: (%d != %d)",
                                                                   ~^
ruby_fann.c:378:33: error: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'void *' [-Wint-conversion]
        fann_set_user_data(ann, self);
                                ^~~~
./fann.h:544:72: note: passing argument to parameter 'user_data' here
FANN_EXTERNAL void FANN_API fann_set_user_data(struct fann *ann, void *user_data);
                                                                       ^
ruby_fann.c:353:62: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
        unsigned int num_layers = RARRAY_LEN(hidden_neurons) + 2;
                     ~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ruby_fann.c:834:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
            for (i = neuron_it->first_con; i < neuron_it->last_con; i++)
                   ~ ~~~~~~~~~~~^~~~~~~~~
ruby_fann.c:836:73: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                rb_ary_push(connection_array, INT2NUM(f->connections[i] - f->first_layer->first_neuron));
                                              ~~~~~~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ruby_fann.c:1173:24: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int len = RARRAY_LEN(inputs);
                 ~~~   ^~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
ruby_fann.c:1226:30: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int num_input = RARRAY_LEN(input);
                 ~~~~~~~~~   ^~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
ruby_fann.c:1227:31: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int num_output = RARRAY_LEN(expected_output);
                 ~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
ruby_fann.c:1537:73: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
    fann_set_cascade_activation_functions(f, fann_activation_functions, cnt);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                               ^~~
ruby_fann.c:1593:24: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int cnt = RARRAY_LEN(cascade_activation_steepnesses);
                 ~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/core/rarray.h:51:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
ruby_fann.c:1682:5: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method(m_rb_fann_standard_class, "get_neurons", get_neurons, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:288:135: note: expanded from macro 'rb_define_method'
#define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                      ^~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:277:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
^
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:255:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _00(__VA_ARGS__, VALUE(*)(VALUE), int); \
                                                                       ^
ruby_fann.c:1780:5: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method(m_rb_fann_shortcut_class, "get_neurons", get_neurons, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:288:135: note: expanded from macro 'rb_define_method'
#define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                      ^~~~~~
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:277:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
^
/Users/dewayne/.rbenv/versions/3.3.0/include/ruby-3.3.0/ruby/internal/anyargs.h:255:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _00(__VA_ARGS__, VALUE(*)(VALUE), int); \
                                                                       ^
13 warnings and 3 errors generated.
make: *** [ruby_fann.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-fann-2.0.2 for inspection.
Results logged to /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/extensions/arm64-darwin-23/3.3.0/ruby-fann-2.0.2/gem_make.out
12:59:53 3.3.0  nibiru:Downloads $ e /Users/dewayne/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/extensions/arm64-darwin-23/3.3.0/ruby-fann-2.0.2/gem_make.out

@ProblemChild77
Copy link

I am having this issue as well. Mac OSX 14.5.

No fix?

@carlosmendes
Copy link

carlosmendes commented Jun 28, 2024

Same error here, Mac OSX 14.5 Intel chip, ruby 3.0.3.
Tried to install some of the most recent versions of the gem and the result was the same error

Building native extensions. This could take a while...
ERROR:  Error installing ruby-fann:
	ERROR: Failed to build gem native extension.

    current directory: /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/ruby-fann-2.0.2/ext/ruby_fann
/Users/carlosmendes/.rbenv/versions/3.0.3/bin/ruby -I /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/3.0.0 -r ./siteconf20240628-47733-wmpgpf.rb extconf.rb
checking for doublefann.h... yes
creating Makefile

current directory: /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/ruby-fann-2.0.2/ext/ruby_fann
make DESTDIR\= clean

current directory: /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/ruby-fann-2.0.2/ext/ruby_fann
make DESTDIR\=
compiling ruby_fann.c
In file included from ruby_fann.c:5:
./fann_augment.h:84:20: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                i, RARRAY_LEN(inputs_i)),
                   ^~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
In file included from ruby_fann.c:5:
./fann_augment.h:83:69: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
                "Number of inputs at [%d] is inconsistent: (%du != %d)",
                                                                   ~^
./fann_augment.h:93:20: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                i, RARRAY_LEN(outputs_i)),
                   ^~~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
In file included from ruby_fann.c:5:
./fann_augment.h:92:69: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
                "Number of outputs at [%d] is inconsistent: (%d != %d)",
                                                                   ~^
ruby_fann.c:378:33: error: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'void *' [-Wint-conversion]
        fann_set_user_data(ann, self);
                                ^~~~
./fann.h:544:72: note: passing argument to parameter 'user_data' here
FANN_EXTERNAL void FANN_API fann_set_user_data(struct fann *ann, void *user_data);
                                                                       ^
ruby_fann.c:353:62: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
        unsigned int num_layers = RARRAY_LEN(hidden_neurons) + 2;
                     ~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ruby_fann.c:834:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
            for (i = neuron_it->first_con; i < neuron_it->last_con; i++)
                   ~ ~~~~~~~~~~~^~~~~~~~~
ruby_fann.c:836:73: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                rb_ary_push(connection_array, INT2NUM(f->connections[i] - f->first_layer->first_neuron));
                                              ~~~~~~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ruby_fann.c:1173:24: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int len = RARRAY_LEN(inputs);
                 ~~~   ^~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
ruby_fann.c:1226:30: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int num_input = RARRAY_LEN(input);
                 ~~~~~~~~~   ^~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
ruby_fann.c:1227:31: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int num_output = RARRAY_LEN(expected_output);
                 ~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
ruby_fann.c:1537:73: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
    fann_set_cascade_activation_functions(f, fann_activation_functions, cnt);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                               ^~~
ruby_fann.c:1593:24: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    unsigned int cnt = RARRAY_LEN(cascade_activation_steepnesses);
                 ~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
ruby_fann.c:1682:5: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method(m_rb_fann_standard_class, "get_neurons", get_neurons, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
#define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                      ^~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
^
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _00(__VA_ARGS__, VALUE(*)(VALUE), int); \
                                                                       ^
ruby_fann.c:1780:5: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method(m_rb_fann_shortcut_class, "get_neurons", get_neurons, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
#define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                      ^~~~~~
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
^
/Users/carlosmendes/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _00(__VA_ARGS__, VALUE(*)(VALUE), int); \
                                                                       ^
12 warnings and 3 errors generated.
make: *** [ruby_fann.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/ruby-fann-2.0.2 for inspection.
Results logged to /Users/carlosmendes/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-21/3.0.0/ruby-fann-2.0.2/gem_make.out

@carlosmendes
Copy link

This forked version solved the problem for OSX: https://github.com/thms/ruby-fann

Added this to the gem file and it worked on OSX and ubuntu
gem 'ruby-fann', git: 'https://github.com/thms/ruby-fann'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants