no matching function for call to ‘Php::Extension::add()

161 views Asked by At

I am using PHP-CPP for creating PHP extension to call c++ function. I have resolved many error after integrating my cpp to example code of cpp by PHP-CPP. But I am stuck at following error,

 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");

My Cpp file is as below

/*
* 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;
    }
}

Kindly suggest me some soilutionto resolve the above error.

1

There are 1 answers

1
lei zhong On

try this extension.add("Demo_Capture", Demo_Capture);