Hello
I'm trying to call R from my C++ OpenCV software and I have problems at runtime.
This is rinside_sample6.cpp adapted:
-----
#include <RInside.h>
#include "opencv/cv.h"
int main(int argc, char **argv) {
CvFont font = cvFont( 1 ); //This breaks all
try {
RInside R(argc, argv);
R["txt"] = "Hello, world!\n";
R.parseEvalQ("cat(txt)");
} catch(std::exception& ex) {
std::cerr << "Exception caught: " << ex.what() << std::endl;
} catch(...) {
std::cerr << "Unknown exception caught" << std::endl;
}
exit(0);
}
-----
Compiled like this:
g++ -I/usr/local/include/opencv -I/usr/share/R/include
-I/usr/local/lib/R/site-library/Rcpp/lib
-I/usr/local/lib/R/site-library/RInside/lib -g -O2 -Wall -s
rinside_sample6.cpp -L/usr/lib/R/lib -lR -lblas -llapack
-L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp
-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib
-L/usr/local/lib/R/site-library/RInside/lib -lRInside
-Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -L/usr/local/lib
-lhighgui -Wl,-rpath,/usr/local/lib -o rinside_sample6
Compilation works, but on execution don't:
$ ./rinside_sample6
Error in readRDS(mapfile) : unknown input format
Error: could not find function "attach"
Exception caught: not found : .AutoloadEnv
Without the try {} catch{}, message is:
$ ./rinside_sample6
Error in readRDS(mapfile) : unknown input format
Error: could not find function "attach"
terminate called after throwing an instance of 'Rcpp::Environment::not_found'
what(): not found : .AutoloadEnv
Aborted
But if this line is removed:
CvFont font = cvFont( 1 );
Compilation works, and execution also:
xavier at corall:~/Desktop$ ./rinside_sample6
Hello, world!
Installed packages:
---------------------------
Rcpp: 0.7.12
RInside: 0.2.2
r-base 2.10.1-2karmic0
r-base-core 2.10.1-2karmic0
r-base-dev 2.10.1-2karmic0
r-base-html 2.10.1-2karmic0
$ uname -a
Linux corall 2.6.33-020633-generic #020633
My OpenCV installation seems to be 2.0.0
Any idea? Thanks in advance!
[Rcpp-devel] Conflict between RInside and OpenCV
5 messages · Dirk Eddelbuettel, Xavi de Blas
On 23 April 2010 at 21:46, Xavi de Blas wrote:
| Hello
|
| I'm trying to call R from my C++ OpenCV software and I have problems at runtime.
|
| This is rinside_sample6.cpp adapted:
|
| -----
| #include <RInside.h>
| #include "opencv/cv.h"
|
| int main(int argc, char **argv) {
| CvFont font = cvFont( 1 ); //This breaks all
|
| try {
| RInside R(argc, argv);
| R["txt"] = "Hello, world!\n";
| R.parseEvalQ("cat(txt)");
|
| } catch(std::exception& ex) {
| std::cerr << "Exception caught: " << ex.what() << std::endl;
| } catch(...) {
| std::cerr << "Unknown exception caught" << std::endl;
| }
|
| exit(0);
| }
| -----
|
| Compiled like this:
|
| g++ -I/usr/local/include/opencv -I/usr/share/R/include
| -I/usr/local/lib/R/site-library/Rcpp/lib
| -I/usr/local/lib/R/site-library/RInside/lib -g -O2 -Wall -s
| rinside_sample6.cpp -L/usr/lib/R/lib -lR -lblas -llapack
| -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp
| -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib
| -L/usr/local/lib/R/site-library/RInside/lib -lRInside
| -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -L/usr/local/lib
| -lhighgui -Wl,-rpath,/usr/local/lib -o rinside_sample6
|
| Compilation works, but on execution don't:
|
| $ ./rinside_sample6
| Error in readRDS(mapfile) : unknown input format
| Error: could not find function "attach"
| Exception caught: not found : .AutoloadEnv
|
| Without the try {} catch{}, message is:
| $ ./rinside_sample6
| Error in readRDS(mapfile) : unknown input format
| Error: could not find function "attach"
| terminate called after throwing an instance of 'Rcpp::Environment::not_found'
| what(): not found : .AutoloadEnv
| Aborted
|
|
| But if this line is removed:
|
| CvFont font = cvFont( 1 );
|
| Compilation works, and execution also:
|
| xavier at corall:~/Desktop$ ./rinside_sample6
| Hello, world!
|
| Installed packages:
| ---------------------------
| Rcpp: 0.7.12
| RInside: 0.2.2
| r-base 2.10.1-2karmic0
| r-base-core 2.10.1-2karmic0
| r-base-dev 2.10.1-2karmic0
| r-base-html 2.10.1-2karmic0
| $ uname -a
| Linux corall 2.6.33-020633-generic #020633
|
| My OpenCV installation seems to be 2.0.0
|
|
| Any idea? Thanks in advance!
No idea whatsoever. That seems very bizarre and implausible. Do you have
anything in your ~/.Profile?
Also, is
-L/usr/local/lib -lhighgui
all you need to link with OpenCV? [ BTW the -L/usr/local/lib is redundant. ]
Also, that seems to be rinsinse_sample0, not 6, no?
Dirk
Regards, Dirk
Hello Dirk
No idea whatsoever. That seems very bizarre and implausible. ?Do you have anything in your ~/.Profile?
Nothing special
Also, is ? ? ?-L/usr/local/lib -lhighgui all you need to link with OpenCV? ?[ BTW the -L/usr/local/lib is redundant. ]
I normally use this: g++ `pkg-config --cflags opencv` kneeAngle.cpp -o kneeAngle `pkg-config --libs opencv` that means: -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml but for this small sample, there's enought with lhighgui
Also, that seems to be rinsinse_sample0, not 6, no?
Yes sorry, i confused trying to send minimal code possible. Is sample 0 Maybe I update Ubuntu system, reinstall OpenCV.... but just prefer to wait if there are some ideas I've been all the day trying different compile options and reducing code, and I feel so unhappy. Thanks for your fast response
On 23 April 2010 at 22:25, Xavi de Blas wrote:
| Hello Dirk | | | > No idea whatsoever. That seems very bizarre and implausible. ?Do you have | > anything in your ~/.Profile? | | Nothing special It is either that file, or an existing .RData you are loading by virtue of initializing R. I can run your example without a problem on an Ubuntu 9.10 box using libhighgui-dev and all it dependents. I used RInside from SVN, but that shouldn't matter. On the machine where I tested this Rcpp is reasonably current but less recent than 0.7.12. | > | > Also, is | > | > ? ? ?-L/usr/local/lib -lhighgui | > | > all you need to link with OpenCV? ?[ BTW the -L/usr/local/lib is redundant. ] | | | I normally use this: | | g++ `pkg-config --cflags opencv` kneeAngle.cpp -o kneeAngle | `pkg-config --libs opencv` | | that means: | | -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml | | but for this small sample, there's enought with lhighgui Agreed. I just inserted -lhighgui right after -llapack, and it links and runs. So no bug here with RInside. | > Also, that seems to be rinsinse_sample0, not 6, no? | | | Yes sorry, i confused trying to send minimal code possible. Is sample 0 | | Maybe I update Ubuntu system, reinstall OpenCV.... but just prefer to | wait if there are some ideas | | I've been all the day trying different compile options and reducing | code, and I feel so unhappy. Thanks for your fast response You created a side-effect. Only you can figure out what you did or what you have in .RData or .Rprofile or related files. There is no problem with your simple test file.
Regards, Dirk
Hello again I deleted .RData and .Rprofile and problem persists. In order to have OpenCV right-working with last ffmpeg i have so much versions and compilations and maybe there's a problem difficult to reproduce. Can you please post your compilation line? I'm glad that it's working for you Thanks 2010/4/23 Dirk Eddelbuettel <edd at debian.org>:
On 23 April 2010 at 22:25, Xavi de Blas wrote: | Hello Dirk | | | > No idea whatsoever. That seems very bizarre and implausible. ?Do you have | > anything in your ~/.Profile? | | Nothing special It is either that file, or an existing .RData you are loading by virtue of initializing R. I can run your example without a problem on an Ubuntu 9.10 box using libhighgui-dev and all it dependents. I used RInside from SVN, but that shouldn't matter. ?On the machine where I tested this Rcpp is reasonably current but less recent than 0.7.12. | > | > Also, is | > | > ? ? ?-L/usr/local/lib -lhighgui | > | > all you need to link with OpenCV? ?[ BTW the -L/usr/local/lib is redundant. ] | | | I ?normally use this: | | g++ `pkg-config --cflags opencv` kneeAngle.cpp -o kneeAngle | `pkg-config --libs opencv` | | that means: | | -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml | | but for this small sample, there's enought with lhighgui Agreed. I just inserted -lhighgui right after -llapack, and it links and runs. ?So no bug here with RInside. | > Also, that seems to be rinsinse_sample0, not 6, no? | | | Yes sorry, i confused trying to send minimal code possible. Is sample 0 | | Maybe I update Ubuntu system, reinstall OpenCV.... but just prefer to | wait if there are some ideas | | I've been all the day trying different compile options and reducing | code, and I feel so unhappy. Thanks for your fast response You created a side-effect. Only you can figure out what you did or what you have in .RData or .Rprofile or related files. There is no problem with your simple test file. -- ?Regards, Dirk