While compiling a Ruby gem's native extension, I get this error according to logs:
LD_LIBRARY_PATH=.:/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/lib "gcc-12 -M -o conftest -I/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0 -I. -I/opt/local/include -I/usr/local/include -I/opt/homebrew/include -I/usr/include -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/openssl#3/include -I/home/linuxbrew/.linuxbrew/opt/readline/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef -fPIC conftest.c -L. -L/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/lib -L/opt/local/lib -Wl,-rpath,/opt/local/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/opt/homebrew/lib -Wl,-rpath,/opt/homebrew/lib -L/usr/lib -Wl,-rpath,/usr/lib -L/home/linuxbrew/.linuxbrew/opt/libyaml/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/libyaml/lib -L/home/linuxbrew/.linuxbrew/opt/openssl#3/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl#3/lib -L/home/linuxbrew/.linuxbrew/opt/readline/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/readline/lib -L. -fstack-protector-strong -L/home/linuxbrew/.linuxbrew/opt/libyaml/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/libyaml/lib -L/home/linuxbrew/.linuxbrew/opt/openssl#3/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl#3/lib -L/home/linuxbrew/.linuxbrew/opt/readline/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/readline/lib -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,-rpath,/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/lib -L/home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/lib -lruby -lm -lc"
In file included from /home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0/ruby/defines.h:16,
from /home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0/ruby/ruby.h:25,
from /home/linuxbrew/.linuxbrew/Cellar/ruby#3.1/3.1.3_1/include/ruby-3.1.0/ruby.h:38,
from conftest.c:1:
/usr/include/stdio.h:781:10: fatal error: bits/sys_errlist.h: No such file or directory
781 | #include <bits/sys_errlist.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
The problem is that in the -I arguments you can see -I/opt/homebrew/include -I/usr/include, and the first of these directories has /opt/homebrew/include/stdio.h which doesn't contain #include <bits/sys_errlist.h>. As far as I understand https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html, it should be used instead of /usr/include/stdio.h. What am I missing and how can I fix the problem?
Versions:
WSL 1.0.3.0
Ubuntu 20.04
Homebrew GCC 12.2.0
Homebrew Ruby 3.1.3
The awful (but working for me) workaround:
Rename /usr/include;
Compile;
Rename it back.
Fetching ruby-filemagic 0.7.2
Installing ruby-filemagic 0.7.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/quantum/.rvm/gems/ruby-2.4.2/gems/ruby-filemagic-0.7.2/ext/filemagic
/Users/quantum/.rvm/rubies/ruby-2.4.2/bin/ruby -r ./siteconf20180207-53723-1uirx0.rb extconf.rb
checking for -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
*** 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.
have_library: checking for -lgnurx... -------------------- no
"gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.4.2 -lpthread -lgmp -ldl -lobjc "
ld: warning: directory not found for option '-L/opt/local/lib'
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.4.2 -lgnurx -lpthread -lgmp -ldl -lobjc "
ld: warning: directory not found for option '-L/opt/local/lib'
ld: library not found for -lgnurx
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13:
14: int t(void) { ; return 0; }
/* end */
--------------------
have_library: checking for magic_open() in -lmagic... -------------------- no
"gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.4.2 -lmagic -lpthread -lgmp -ldl -lobjc "
conftest.c:13:57: error: use of undeclared identifier 'magic_open'
int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return !p; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return !p; }
/* end */
"gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.4.2 -lmagic -lpthread -lgmp -ldl -lobjc "
ld: warning: directory not found for option '-L/opt/local/lib'
ld: library not found for -lmagic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void magic_open();
14: int t(void) { magic_open(); return 0; }
/* end */
--------------------
It looks like the magic_open is failing? How can I fix this?
AAA,
found the solution which helped me, spent like almost two days on it, so if it would save someones time posting here.
brew install libmagic
and then
env ARCHFLAGS="-arch x86_64" gem install -v 0.7.1 ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
make sure though that you are installing required version in gem install -v 0.7.1 ruby-filemagic
sudo brew install libmagic fixed that for me
We are running on Ubuntu 14.04, with Gitlab 9.3.7, which works fine. We are trying to update to the latest security patch of Gitlab v9.3.8, but it gives us this error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/re2-1.0.0/ext/re2
/usr/local/bin/ruby -r ./siteconf20170720-19622-15i0edf.rb extconf.rb
checking for main() in -lstdc++... yes
checking for stdint.h... yes
checking for rb_str_sublen()... yes
checking for main() in -lre2... no
You must have re2 installed and specified with --with-re2-dir, please see https://github.com/google/re2/wiki/Install
*** 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=/usr/local/bin/$(RUBY_BASE_NAME)
--with-re2-dir
--without-re2-dir
--with-re2-include
--without-re2-include=${re2-dir}/include
--with-re2-lib
--without-re2-lib=${re2-dir}/lib
--with-stdc++lib
--without-stdc++lib
--with-re2lib
--without-re2lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/git/gitlab/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/re2-1.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/re2-1.0.0 for inspection.
Results logged to /home/git/gitlab/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/re2-1.0.0/gem_make.out
An error occurred while installing re2 (1.0.0), and Bundler cannot continue.
Make sure that `gem install re2 -v '1.0.0'` succeeds before bundling.
In Gemfile:
re2
The mkmf.log file contains:
have_library: checking for main() in -lstdc++... -------------------- yes
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lstdc++ -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return !p; }
/* end */
--------------------
have_header: checking for stdint.h... -------------------- yes
"gcc -E -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdint.h>
/* end */
--------------------
have_func: checking for rb_str_sublen()... -------------------- yes
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -lstdc++ -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lstdc++ -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_str_sublen; return !p; }
/* end */
--------------------
have_library: checking for main() in -lre2... -------------------- no
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -lstdc++ -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lre2 -lstdc++ -lpthread -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lre2
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return !p; }
/* end */
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -lstdc++ -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lre2 -lstdc++ -lpthread -ldl -lcrypt -lm -lc"
conftest.c:13:13: error: conflicting types for ‘main’
extern void main();
^
conftest.c:5:5: note: previous definition of ‘main’ was here
int main(int argc, char **argv)
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void main();
14: int t(void) { main(); return 0; }
/* end */
--------------------
I've tried adding ruby-dev and ruby2.3-dev as we are using Ruby 2.3. No changes in the update. As this is a fairly recent patch, Gitlab has no further information on their site, and the installation instructions for re2 have not helped.
I was able to install the re2-gem after installing the lib:
apt-get install libre2-dev
I had same problem
It works for me, try it on you own risk
Ubuntu 14.04 have no libre2-dev
https://launchpad.net/ubuntu/+source/re2
I installed it from sources
https://github.com/google/re2/wiki/Install
cd /tmp
git clone https://github.com/google/re2.git
cd re2/
make
make test
sudo checkinstall -D --install=no
sudo dpkg -i re2_20170720-1_amd64.deb
And then run
ldconfig
I have the same error on macOS Big Sur. And below installation solve the problem
brew install re2
Hi I've just encountered the same error. At least we're not the only one.
I've made an issue in GitLab: https://gitlab.com/gitlab-org/gitlab-ce/issues/35342
I am unable to install ruby-opencv gem.
Here's what I have done so far.
Installed openCV with
sudo apt-get install libopencv-dev
Then tried installing ruby-opencv gem with
gem install ruby-opencv
But I got the following error
➜ test gem install ruby-opencv
Building native extensions. This could take a while...
ERROR: Error installing ruby-opencv:
ERROR: Failed to build gem native extension.
/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
>> Check the required libraries...
checking for main() in -lopencv_calib3d... yes
checking for main() in -lopencv_contrib... yes
checking for main() in -lopencv_core... yes
checking for main() in -lopencv_features2d... yes
checking for main() in -lopencv_flann... yes
checking for main() in -lopencv_gpu... 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=/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
--with-opencv-dir
--without-opencv-dir
--with-opencv-include
--without-opencv-include=${opencv-dir}/include
--with-opencv-lib
--without-opencv-lib=${opencv-dir}/lib
--with-libxml2-dir
--without-libxml2-dir
--with-libxml2-include
--without-libxml2-include=${libxml2-dir}/include
--with-libxml2-lib
--without-libxml2-lib=${libxml2-dir}/lib
--with-opencv_calib3dlib
--without-opencv_calib3dlib
--with-opencv_contriblib
--without-opencv_contriblib
--with-opencv_corelib
--without-opencv_corelib
--with-opencv_features2dlib
--without-opencv_features2dlib
--with-opencv_flannlib
--without-opencv_flannlib
--with-opencv_gpulib
--without-opencv_gpulib
extconf.rb:53:in `block in <main>': libopencv_gpu not found. (RuntimeError)
from extconf.rb:52:in `each'
from extconf.rb:52:in `<main>'
It seems there is no libopencv-gpu dependency installed.
I tried to install it with apt-get but couldn't succeed as no repository was found.
Can any one help me how to install ruby-opencv gem?
UPDATE
added mkmf.log content
➜ test cat /home/ckgagan/.rvm/gems/ruby-1.9.3-p484/gems/ruby-opencv-0.0.11/ext/opencv/mkmf.log
have_library: checking for main() in -lopencv_calib3d... -------------------- yes
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_library: checking for main() in -lopencv_contrib... -------------------- yes
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_library: checking for main() in -lopencv_core... -------------------- yes
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_library: checking for main() in -lopencv_features2d... -------------------- yes
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_library: checking for main() in -lopencv_flann... -------------------- yes
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_library: checking for main() in -lopencv_gpu... -------------------- no
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_gpu -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:53: error: ‘main’ undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"gcc -o conftest -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-linux -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -I/usr/include -I/usr/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -Wl,-R/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -L/home/ckgagan/.rvm/rubies/ruby-1.9.3-p484/lib -lruby -lopencv_gpu -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:4:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
/usr/bin/ld: cannot find -lopencv_gpu
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { main(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
Thanks
I just successfully install this gem ruby-opencv after hours investigation with many failures.
You have to download 2.x archive from http://opencv.org/downloads.html, NOTE, you can't install the latest version which is 3.0.beta, I'm the one who downloaded 3.0.beta initially, and got many failures.
Then install required packages and make install opencv according to this instruction
http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
From this installation instruction, you don't need to build opencv_contrib, just build opencv, that's all.
Finally, execute gem i ruby-opencv
Good luck.
Try installing the gem with the path to your opencv install as per the instructions on their github page.
gem install ruby-opencv -- --with-opencv-dir=/path/to/opencvdir
#lan Delairre, this is my note while installing opencv, hope this is helpful to you:
Download opencv-2.4.10 from http://opencv.org/downloads.html
Build libs
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
If got some error, try follow this instruction to install packages
http://milq.github.io/install-opencv-ubuntu-debian/
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install libgtk2.0-dev
sudo apt-get install python-dev python-numpy
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
cd ~/src/opencv-2.4.10
mkdir release
cd release
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..
make -j7
sudo make install
sudo ldconfig
While trying to build the mysql2 gem with ruby 1.9.2-p320 on Fedora 16, I ran into this error,
reproducible like so:
gremlin:mysql2 $ cat conftest.c
#include "ruby.h"
/*top*/
int main() {return 0;}
int t() {
void ((*volatile p)());
p = (void ((*)()))rb_thread_blocking_region;
return 0;
}
gremlin:mysql2 $ gcc -o conftest -I/usr/local/include/ruby-1.9.1/i686-linux \
-I/usr/local/include/ruby-1.9.1/ruby/backward
-I/usr/local/include/ruby-1.9.1 -I.
-I/usr/local/include/ruby-1.9.1/
-D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter
-Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers
-Wno-long-long conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L.
-rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib
-lruby-static -lpthread -lrt -ldl -lnss3 -lcrypt -lm -lc
/usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o):
In function `__md5_crypt_r':
(.text+0x96): undefined reference to `NSSLOW_Init'
/usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o):
In function `__md5_crypt_r':
(.text+0xb1): undefined reference to `NSSLOWHASH_NewContext'
... and many more messages for other global functions in the nsslowhash library,
which it looks like /usr/lib/libcrypt.a expects to have available, but I don't have
it installed, and can't find the source for.
Actually, that's not totally true. I found nsslowhash as part of
the Mozilla-Central build for Firefox, but when I run nm on the compiled
.a and .so files, none of them define anything that matches NSSLOW.
So where do these names come from?
Any help appreciated.
Problem solved by adding -lfreebl3 to the LIBS CONFIG setting.