Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do i create a .so file that contains only C++ code wrapped in C code - OpenCV related

On Ubuntu Saucy 64bit in termial using g++ Im attempting to wrap OpenCV in a language without a strong C++ ffi so im attempting to use C++ to C wrappers to aid in doing this... Here is the small peice of the files Im trying to convert just to get a feel for it(opencv_generated.hpp and opencv_generated.cpp at this link https://github.com/arjuncomar/opencv-raw)

opencv_generated.hpp:

#include <opencv2/opencv.hpp>
#include <vector>
#ifndef __OPENCV_GENERATED_HPP
#define __OPENCV_GENERATED_HPP
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {
Mat* cv_imread(String* filename, int flags);
void cv_imshow(String* winname, Mat* mat);
bool cv_imwrite(String* filename, Mat* img, vector_int* params);}

opencv_generated.cpp:

 #include "opencv_generated.hpp"
 using namespace cv;
 using namespace std;
 using namespace flann;
 using namespace cvflann;
 extern "C" {

 Mat* cv_imread(String* filename, int flags) {
 return new Mat(cv::imread(*filename, flags));
 }
 void cv_imshow(String* winname, Mat* mat) {
     cv::imshow(*winname, *mat);
 }
 bool cv_imwrite(String* filename, Mat* img, vector_int* params) {
     return cv::imwrite(*filename, *img, *params);
 }}

Am new to C wrappers for C++ and am trying to compile with

 g++ -Wall -dynamiclib  -I/home/w/test/glue.hpp -I/home/w/test/glue.cpp  -o test.so

im getting error:

g++: fatal error: no input files...im in the directory my 
glue.hpp and glue.cpp files are in so what am i doing wrong....
any help == greatly valued=)

How do i create a .so file that contains only C++ code wrapped in C code - OpenCV related

On Ubuntu Saucy 64bit in termial using g++ Im attempting to wrap OpenCV in a language without a strong C++ ffi so im attempting to use C++ to C wrappers to aid in doing this... Here is the small peice of the files Im trying to convert just to get a feel for it(opencv_generated.hpp and opencv_generated.cpp at this link https://github.com/arjuncomar/opencv-raw)

opencv_generated.hpp:opencv_generated hpp:

#include "cxcore.h"
#include "cv.h"
#include <opencv2/core/core.hpp>

#include <opencv2/opencv.hpp>
#include <vector>
#ifndef __OPENCV_GENERATED_HPP
#define __OPENCV_GENERATED_HPP
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {
Mat* cv_imread(String* filename, int flags);
void cv_imshow(String* winname, Mat* mat);
bool cv_imwrite(String* filename, Mat* img, vector_int* params);}

opencv_generated.cpp:

 #include "opencv_generated.hpp"
 using namespace cv;
 using namespace std;
 using namespace flann;
 using namespace cvflann;
 extern "C" {

 Mat* cv_imread(String* filename, int flags) {
 return new Mat(cv::imread(*filename, flags));
 }
 void cv_imshow(String* winname, Mat* mat) {
     cv::imshow(*winname, *mat);
 }
 bool cv_imwrite(String* filename, Mat* img, vector_int* params) {
     return cv::imwrite(*filename, *img, *params);
 }}

Am new to C wrappers for C++ and am trying to compile with

 

g++ -Wall -dynamiclib -I/home/w/test/glue.hpp -I/home/w/test/glue.cpp -I/home/w/test/opencv_generated.hpp -I/home/w/test/opencv_generated.cpp -o test.so

test.so

im getting error:

g++: fatal error: no input files...im files

...im in the directory my glue.hpp opencv_generated.cpp and glue.cpp opencv_generated.hpp files are in so what am i doing wrong.... any wrong??....any help == greatly valued=) valued=)