Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用g+;在Eclipse IDE中创建DLL类时出错+;编译程序_C++_Eclipse_G++ - Fatal编程技术网

C++ 使用g+;在Eclipse IDE中创建DLL类时出错+;编译程序

C++ 使用g+;在Eclipse IDE中创建DLL类时出错+;编译程序,c++,eclipse,g++,C++,Eclipse,G++,我在Eclipse中做了一个项目,用g++编译器导出一个dll类。我的操作系统是Ubuntu,应用程序将在Ubuntu操作系统中运行。我创建了一个共享项目 我有编译错误 expected constructor, destructor, or type conversion before ‘(’ token OCR_dll.h /OCR line 19 C/C++ Problem 错误发生在#define DLLCLASS_uudeclspec(dllexport)以及如何解决错

我在Eclipse中做了一个项目,用g++编译器导出一个dll类。我的操作系统是Ubuntu,应用程序将在Ubuntu操作系统中运行。我创建了一个共享项目

我有编译错误

expected constructor, destructor, or type conversion before ‘(’ token   OCR_dll.h   /OCR    line 19 C/C++ Problem
错误发生在
#define DLLCLASS_uudeclspec(dllexport)
以及如何解决错误。多谢各位

我的dll代码头文件是

OCR_dll.h
#ifndef OCR_DLL_H_
#define OCR_DLL_H_
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <tesseract/baseapi.h>
#include <iostream>
#include "Define.h"

#ifdef EXPORT
#define DLLCLASS __declspec(dllexport)
#else
#define DLLCLASS __declspec(dllimport)
#endif

using namespace cv;

#ifdef __cplusplus
extern "C" {
#endif

namespace VIDEOANALYTICS_PLATFORM {
    class iOCR{

        public:
            virtual ~iOCR(){}
            virtual int preProcessing(Mat &img) = 0;
            virtual int textExtraction(Mat &img) = 0;
    };

    class OCR : public iOCR{

        public:
            OCR(){}
            ~OCR(){ ; }
            int preProcessing(Mat &img);
            int textExtraction(Mat &img);
        private:


    };

    extern "C"{ DLLCLASS iOCR* __stdcall  createOCRObject(); };
}

#ifdef __cplusplus
}
#endif

#endif /* OCR_DLL_H_ */
OCR\u dll.h
#ifndef OCR\u DLL\H_
#定义OCR\u DLL\u H_
#包括
#包括
#包括
#包括
#包括
#包括
#包括“Define.h”
#ifdef导出
#定义DLLCLASS\uuu declspec(dllexport)
#否则
#定义DLLCLASS\uuu declspec(dllimport)
#恩迪夫
使用名称空间cv;
#ifdef_uucplusplus
外部“C”{
#恩迪夫
命名空间视频分析平台{
类iOCR{
公众:
虚拟~iOCR(){}
虚拟整数预处理(Mat和img)=0;
虚拟整数文本提取(Mat和img)=0;
};
类别OCR:公共iOCR{
公众:
OCR(){}
~OCR(){;}
int预处理(Mat和img);
int文本提取(Mat和img);
私人:
};
外部“C”{DLLCLASS iOCR*u stdcall createOCRObject();};
}
#ifdef_uucplusplus
}
#恩迪夫
#endif/*OCR\u DLL\u H\u*/

我找到了解决方案。在Linux环境中,dll被称为共享库。 我创建共享库的方法是

Headerfile  
    #ifndef OCR_DLL_H_   
    #define OCR_DLL_H_

    #include <opencv/cv.h>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <tesseract/baseapi.h>
    #include <iostream>
    #include "Define.h"


    using namespace cv;



    namespace VIDEOANALYTICS_PLATFORM {
        class iOCR{

            public:
                virtual ~iOCR(){}
                virtual int preProcessing(Mat &img) = 0;
                virtual int textExtraction(Mat &img) = 0;
        };

        class OCR : public iOCR{

            public:
                OCR(){}
                ~OCR(){ ; }
                int preProcessing(Mat &img);
                int textExtraction(Mat &img);
            private:


        };



    }


    #endif /* OCR_DLL_H_ */

CPP file
#include "OCR_dll.h"



namespace VIDEOANALYTICS_PLATFORM {
    extern "C" iOCR* create_object(){
        iOCR *p = new OCR();
        return p;
    }

    extern "C" void destroy_object( iOCR* object )
    {
      delete object;
    }

    int OCR::preProcessing(Mat &img){


        return SUCCESS;
    }

    int OCR::textExtraction(Mat &img){


        return SUCCESS;
    }
}

MAKEFILE
g++ -fPIC -shared OCR_dll.cpp -o OCR_dll.so
Headerfile
#ifndef OCR_DLL_H_
#定义OCR\u DLL\u H_
#包括
#包括
#包括
#包括
#包括
#包括“Define.h”
使用名称空间cv;
命名空间视频分析平台{
类iOCR{
公众:
虚拟~iOCR(){}
虚拟整数预处理(Mat和img)=0;
虚拟整数文本提取(Mat和img)=0;
};
类别OCR:公共iOCR{
公众:
OCR(){}
~OCR(){;}
int预处理(Mat和img);
int文本提取(Mat和img);
私人:
};
}
#endif/*OCR\u DLL\u H\u*/
CPP文件
#包括“OCR_dll.h”
命名空间视频分析平台{
外部“C”iOCR*创建_对象(){
iOCR*p=新的OCR();
返回p;
}
外部“C”无效销毁对象(iOCR*对象)
{
删除对象;
}
int OCR::预处理(Mat和img){
回归成功;
}
int OCR::文本提取(Mat和img){
回归成功;
}
}
生成文件
g++-fPIC-shared OCR_dll.cpp-o OCR_dll.so
然后我们可以为一个类创建共享库对象