Re: [Rd] unable to load shared object - opencv

From: Simon Urbanek <simon.urbanek_at_r-project.org>
Date: Thu, 08 Nov 2012 15:26:54 -0500

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
>
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 08 Nov 2012 - 20:30:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 08 Nov 2012 - 22:10:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive