调用'Php :: Extension :: add()没有匹配函数

时间:2016-12-14 09:32:01

标签: php c++ php-extension php-cpp

我使用PHP-CPP创建PHP扩展来调用c ++函数。 我通过PHP-CPP将cpp集成到cpp的示例代码后解决了许多错误。但是我坚持跟随错误,

 CapPicture.cpp: In function ‘void* get_module()’:
CapPicture.cpp:72:45: error: no matching function for call to ‘Php::Extension::add(const char [13])’
   extension.add<Demo_Capture>("Demo_Capture");

我的Cpp文件如下

/*
* Copyright(C) 2010,Hikvision Digital Technology Co., Ltd 
* 
*/

#include <phpcpp.h>
#include <iostream>
#include <stdlib.h>

#include "public.h"
#include "CapPicture.h"
#include <stdio.h>
/*******************************************************************
      Function:   Demo_Capture
   Description:   Capture picture.
     Parameter:   (IN)   none 
        Return:   0--success£¬-1--fail.   
**********************************************************************/
int Demo_Capture()
{
    // Php::out << "test" << std::endl;
    //return 11;        
    NET_DVR_Init();
    long lUserID;
    //login
    NET_DVR_DEVICEINFO_V30 struDeviceInfo;
    char ipaddress[] = "172.4.1.162";
    WORD port = 8000 ;
    char uname[] = "admin" ;
    char password[] = "121212" ;
    //NET_DVR_Login_V30(char *sDVRIP, WORD wDVRPort, char *sUserName, char *sPassword, LPNET_DVR_DEVICEINFO_V30 lpDeviceInfo);
    lUserID = NET_DVR_Login_V30(ipaddress, port, uname, password, &struDeviceInfo);
    if (lUserID < 0)
    {
        printf("pyd1---Login error, %d\n", NET_DVR_GetLastError());
        return HPR_ERROR;
    }


    NET_DVR_JPEGPARA strPicPara = {0};
    strPicPara.wPicQuality = 2;
    strPicPara.wPicSize = 0;
    int iRet;
    //iRet = NET_DVR_CaptureJPEGPicture(lUserID, struDeviceInfo.    , &strPicPara, "./ssss.jpeg");
    char path[] = "./ssss.jpeg" ;
    iRet = NET_DVR_CaptureJPEGPicture(lUserID, struDeviceInfo.byStartChan, &strPicPara,path);
    if (!iRet)
    {
        printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
        return HPR_ERROR;
    }

    //logout
    NET_DVR_Logout_V30(lUserID);
    NET_DVR_Cleanup();

    return HPR_OK;

}

extern "C" {
    PHPCPP_EXPORT void *get_module() {
        static Php::Extension extension("my_extension1", "1.0");  
        // extension.add("Demo_Capture",(int)Demo_Capture);
        extension.add<Demo_Capture>("Demo_Capture");
        return extension;
    }
}

请建议我解决上述错误。

1 个答案:

答案 0 :(得分:-1)

试试这个 extension.add(&#34; Demo_Capture&#34;,Demo_Capture);