Ask A Question


You’re not receiving notifications from this thread.

Installing ruby_opencv gem results in cannot find opencv_contrib error

William Jones asked in Gems / Libraries

I am trying to install the ruby_opencv gem but it can't find opencv_contrib. I used the command 'gem install ruby-opencv -- --with-opencv-dir=/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir' which is where is loaded opencv. I have done some google searches but I can't find anything that helps. I am using Ruby 2.5.3 and Rails The mkmf.log contains the following,

have_library: checking for -lopencv_contrib... -------------------- no

"gcc -o conftest -I/home/wjones/.rbenv/versions/2.5.3/include/ruby-2.5.0/x86_64-linux -I/home/wjones/.rbenv/versions/2.5.3/include/ruby-2.5.0/ruby/backward -I/home/wjones/.rbenv/versions/2.5.3/include/ruby-2.5.0 -I. -I/usr/include -I/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir/include -I/home/wjones/.rbenv/versions/2.5.3/include -O3 -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 -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict -fPIC conftest.c -L. -L/home/wjones/.rbenv/versions/2.5.3/lib -Wl,-rpath,/home/wjones/.rbenv/versions/2.5.3/lib -L/usr/lib -Wl,-rpath,/usr/lib -L/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir/lib -Wl,-rpath,/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir/lib -L. -L/home/wjones/.rbenv/versions/2.5.3/lib -fstack-protector -rdynamic -Wl,-export-dynamic -lopencv_calib3d -lstdc++ -Wl,-rpath,/home/wjones/.rbenv/versions/2.5.3/lib -L/home/wjones/.rbenv/versions/2.5.3/lib -lruby -lopencv_contrib -lopencv_calib3d -lstdc++ -lpthread -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lopencv_contrib
collect2: error: ld returned 1 exit status
checked program was:
/* begin /
1: #include "ruby.h"
3: /*top
4: extern int t(void);
5: int main(int argc, char *argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
11: return 0;
12: }
14: int t(void) { ; return 0; }
end */

The output from the install is as follows,

wjones@WJONES-LT:/mnt/c/Users/wjones/sites/musclesound-rails$ gem install ruby-opencv -- --with-opencv-dir=/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir
Building native extensions with: '--with-opencv-dir=/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir'
This could take a while...
/home/wjones/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
ERROR: Error installing ruby-opencv:
ERROR: Failed to build gem native extension.

current directory: /home/wjones/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/ruby-opencv-0.0.18/ext/opencv

/home/wjones/.rbenv/versions/2.5.3/bin/ruby -r ./siteconf20210831-1654-prpzjm.rb extconf.rb --with-opencv-dir=/mnt/c/Users/wjones/sites/musclesound-rails/opencv/my_build_dir

Check the required libraries...
checking for -lstdc++... yes
checking for -lopencv_calib3d... yes
checking for -lopencv_contrib... no
*** extconf.rb failed ***

Any help you could give would be great.


Did you ever get anywhere with this?


Unfortunately, no.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,038+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.