[Rd] unable to load shared object - opencv

Simon Urbanek simon.urbanek at r-project.org
Thu Nov 8 21:26:54 CET 2012


On Nov 8, 2012, at 3:19 PM, niandra wrote:

> Hi all
> 
> i'm trying to use the opencv's function into R.
> 
> i wrote a simple script, just for try to understand how use c++ in R, it
> loads an image and write it with a different name (i know it ), and then
> write "Hello, World". The file is names prova2.cpp (is the first time i try
> to use c++ )
> 
> #include <stdio.h>
> #include <opencv/cv.h>
> #include <opencv2/core/core.hpp>
> #include <opencv2/highgui/highgui.hpp>
> #include <opencv/highgui.h>
> #include <opencv/cv.h> 
> #include <R.h>
> #include <Rinternals.h>
> 
> extern "C" SEXP provaR(void) {
> cv::Mat gravit;
> gravit=cv::imread("imm.jpg");
> cv::imwrite("imm_dop.jpg",gravit);
> Rprintf("Hello, World!nn");
> return R_NilValue;
> }
> 
> Now in the terminal  i type R CMD SHLIB  prova2.cpp to create the file
> prova2.so and this happen without error.
> 
> In R i type dyn.load("prova2.so") and get this error:
> 
> Errore in dyn.load("prova2.so") : 
>  unable to load shared object
> '/Users/niandra/Desktop/statistico/r/builtpack/ProvaScript/prova2.so':
> 
> dlopen(/Users/niandra/Desktop/statistico/r/builtpack/ProvaScript/prova2.so,
> 6): Symbol not found: __ZN2cv11_InputArrayC1ERKNS_3MatE
>  Referenced from:
> /Users/niandra/Desktop/statistico/r/builtpack/ProvaScript/prova2.so
>  Expected in: flat namespace
> in /Users/niandra/Desktop/statistico/r/builtpack/ProvaScript/prova2.so
> 
> I understand that the problem is because i should tell R where to find the
> opencv library, but i really don't know how do it.
> 

add the necessary -l flags (see your configuration or pkgconfig) to R CMD SHLIB

Cheers,
S


> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/unable-to-load-shared-object-opencv-tp4648958.html
> Sent from the R devel mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



More information about the R-devel mailing list