Line Suppression State Error LNK2019 unresolved external symbol "void __cdecl dcamcon_show_dcamerr(struct tag_dcam *,enum DCAMERR,char const *,char const *,...)"

Subhash Chandra Ranga 6 Reputation points
2021-02-11T11:28:50.947+00:00

/**
@Gaydamak access_image.cpp
@brief sample code to access image.
@Nguyễn Thịnh This program accesses the captured image. The function used to access image is changed by the directive "USE_COPYFRAME".
@Nguyễn Thịnh This program outputs raw data if the directive "OUTPUT_IMAGE" is enable.
@remarks dcambuf_lockframe
@remarks dcambuf_copyframe
*/

include "../misc/console4.h"

include "../misc/common.h"

/**
@def USE_COPYFRAME
*
*0: dcambuf_lockframe is used to access image.\n
* This function gets the pointer of image, so it is necessary to copy the target ROI from this pointer.
*
*1: dcambuf_copyframe is used to access image.\n
* This function sets the pointer of buffer to get image. DCAM copies the target ROI to this buffer
*/

define USE_COPYFRAME 1 // 0: call dcambuf_lockframe to access image, 1: call dcambuf_copyframe to access image

/**
@def OUTPUT_IMAGE
*
*0: not output image\n
*
*1: output the accessed image with sequential name.\n
*/

define OUTPUT_IMAGE 1 // 0: not output, 1: output the accessed image by raw data

/*
@def BINNING_VALUE
*
*n: This value is set as a binning parameter.
* This value is set to the property DCAM_IDPROP_BINNING.
*/

define BINNING_VALUE 2

/*
@def SUBARRAY_HORZ_OFFSEt
*
*n: This value is set as a horizontal offset of subbarray.
* This value is set to the property DCAM_IDPROP_SUBARRAYHPOS.
* This value means the position of the sensor coordinate. In other words, this position is the coordinate of the binning 1x1.
*/

define SUBARRAY_HORZ_OFFSET 128

/*
@def SUBARRAY_HORZ_SIZE
*
*n: This value is set as a horizontal length of subbarray.
* This value is set to the property DCAM_IDPROP_SUBARRAYHSIZE.
* This value means the length of the sensor coordinate. In other words, this position is the coordinate of the binning 1x1.
*/

define SUBARRAY_HORZ_SIZE 512

/*
@def SUBARRAY_VERT_OFFSEt
*
*n: This value is set as a vertical offset of subbarray.
* This value is set to the property DCAM_IDPROP_SUBARRAYVPOS.
* This value means the position of the sensor coordinate. In other words, this position is the coordinate of the binning 1x1.
*/

define SUBARRAY_VERT_OFFSET 128

/*
@def SUBARRAY_VERT_SIZE
*
*n: This value is set as a vertical length of subbarray.
* This value is set to the property DCAM_IDPROP_SUBARRAYVSIZE.
* This value means the length of the sensor coordinate. In other words, this position is the coordinate of the binning 1x1.
*/

define SUBARRAY_VERT_SIZE 512

/**
@brief copy image to the specified buffer by the specified area.
@Paramjeet Dahiya hdcam DCAM handle
@Paramjeet Dahiya iFrame frame index
@Paramjeet Dahiya buf buffer to copy image
@Paramjeet Dahiya rowbytes rowbytes of buf
@Paramjeet Dahiya ox horizontal offset
@Paramjeet Dahiya oy vertical offset
@Paramjeet Dahiya cx horizontal size
@Paramjeet Dahiya cy vertical size
@return result of copy image
*/

BOOL copy_targetarea(HDCAM hdcam, int32 iFrame, void* buf, int32 rowbytes, int32 ox, int32 oy, int32 cx, int32 cy)
{
DCAMERR err;

// prepare frame param  
DCAMBUF_FRAME bufframe;  
memset(&bufframe, 0, sizeof(bufframe));  
bufframe.size = sizeof(bufframe);  
bufframe.iFrame = iFrame;  

if USE_COPYFRAME

// set user buffer information and copied ROI  
bufframe.buf = buf;  
bufframe.rowbytes = rowbytes;  
bufframe.left = ox;  
bufframe.top = oy;  
bufframe.width = cx;  
bufframe.height = cy;  

// access image  
err = dcambuf_copyframe(hdcam, &bufframe);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcambuf_copyframe()");  
    return FALSE;  
}  

else

// access image  
err = dcambuf_lockframe(hdcam, &bufframe);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcambuf_lockframe()");  
    return FALSE;  
}  

if (bufframe.type != DCAM_PIXELTYPE_MONO16)  
{  
    printf("not implement pixel type\n");  
    return FALSE;  
}  

// copy target ROI  
int32 copyrowbytes = cx * 2;  
char* pSrc = (char*)bufframe.buf + oy * bufframe.rowbytes + ox * 2;  
char* pDst = (char*)buf;  

int y;  
for (y = 0; y < cy; y++)  
{  
    memcpy_s(pDst, rowbytes, pSrc, copyrowbytes);  

    pSrc += bufframe.rowbytes;  
    pDst += rowbytes;  
}  

endif

return TRUE;  

}

/*
@brief set binning
@Paramjeet Dahiya hdcam: DCAM handle
@Paramjeet Dahiya binning: value of binning
@return result of setting to binning parameter
*/
BOOL set_binning(HDCAM hdcam, int32 binning)
{
DCAMERR err;

// check whether the camera supports or not. (refer sample program propertylist to get the list of support values)  
double v = binning;  
err = dcamprop_queryvalue(hdcam, DCAM_IDPROP_BINNING, &v);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_queryvalue()", "IDPROP:BINNING, VALUE:%d", binning);  
    return FALSE;  
}  

// set binning value to the camera  
err = dcamprop_setvalue(hdcam, DCAM_IDPROP_BINNING, binning);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:BINNING, VALUE:%d", binning);  
    return FALSE;  
}  

return TRUE;  

}

/**
@brief set subarray
@Paramjeet Dahiya hdcam: DCAM handle
@Paramjeet Dahiya hpos: horizontal offset
@Paramjeet Dahiya hsize: horizontal size
@Paramjeet Dahiya vpos: vertical offset
@Paramjeet Dahiya vsize: vertical size
@return result of setting to subarray paramter
*/
BOOL set_subarray(HDCAM hdcam, int32 hpos, int32 hsize, int32 vpos, int32 vsize)
{
DCAMERR err;

// set subarray mode off. This setting is not mandatory, but you have to control the setting order of offset and size when mode is on.   
err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYMODE, DCAMPROP_MODE__OFF);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYMODE, VALUE:OFF");  
    return FALSE;  
}  

err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYHPOS, hpos);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYHPOS, VALUE:%d", hpos);  
    return FALSE;  
}  

err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYHSIZE, hsize);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYHSIZE, VALUE:%d", hsize);  
    return FALSE;  
}  

err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYVPOS, vpos);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYVPOS, VALUE:%d", vpos);  
    return FALSE;  
}  

err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYVSIZE, vsize);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYVSIZE, VALUE:%d", vsize);  
    return FALSE;  
}  

// set subarray mode on. The combination of offset and size is checked on this timing.  
err = dcamprop_setvalue(hdcam, DCAM_IDPROP_SUBARRAYMODE, DCAMPROP_MODE__ON);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_setvalue()", "IDPROP:SUBARRAYMODE, VALUE:ON");  
    return FALSE;  
}  

return TRUE;  

}

/**
@brief get image information from properties.
@Paramjeet Dahiya hdcam DCAM handle
@Paramjeet Dahiya pixeltype DCAM_PIXELTYPE value
@Paramjeet Dahiya width image width
@Paramjeet Dahiya rowbytes image rowbytes
@Paramjeet Dahiya height image height
*/
void get_image_information(HDCAM hdcam, int32& pixeltype, int32& width, int32& rowbytes, int32& height)
{
DCAMERR err;

double v;  

// image pixel type(DCAM_PIXELTYPE_MONO16, MONO8, ... )  
err = dcamprop_getvalue(hdcam, DCAM_IDPROP_IMAGE_PIXELTYPE, &v);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_getvalue()", "IDPROP:IMAGE_PIXELTYPE");  
    return;  
}  
else  
    pixeltype = (int32)v;  

// image width  
err = dcamprop_getvalue(hdcam, DCAM_IDPROP_IMAGE_WIDTH, &v);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_getvalue()", "IDPROP:IMAGE_WIDTH");  
    return;  
}  
else  
    width = (int32)v;  

// image row bytes  
err = dcamprop_getvalue(hdcam, DCAM_IDPROP_IMAGE_ROWBYTES, &v);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_getvalue()", "IDPROP:IMAGE_ROWBYTES");  
    return;  
}  
else  
    rowbytes = (int32)v;  

// image height  
err = dcamprop_getvalue(hdcam, DCAM_IDPROP_IMAGE_HEIGHT, &v);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamprop_getvalue()", "IDPROP:IMAGE_HEIGHT");  
    return;  
}  
else  
    height = (int32)v;  

}

/**
@brief sample used to process image after capturing.
@Nguyễn Thịnh This function copies the target area that is 10% of full area on the center.
@Paramjeet Dahiya hdcam DCAM handle
@sa get_image_information, copy_targetarea
*/
void sample_access_images(HDCAM hdcam)
{
DCAMERR err;

// transferinfo param  
DCAMCAP_TRANSFERINFO captransferinfo;  
memset(&captransferinfo, 0, sizeof(captransferinfo));  
captransferinfo.size = sizeof(captransferinfo);  

// get number of captured image  
err = dcamcap_transferinfo(hdcam, &captransferinfo);  
if (failed(err))  
{  
    dcamcon_show_dcamerr(hdcam, err, "dcamcap_transferinfo()");  
    return;  
}  

if (captransferinfo.nFrameCount < 1)  
{  
    printf("not capture image\n");  
    return;  
}  

// get image information  
int32 pixeltype = 0, width = 0, rowbytes = 0, height = 0;  
get_image_information(hdcam, pixeltype, width, rowbytes, height);  

if (pixeltype != DCAM_PIXELTYPE_MONO16)  
{  
    printf("not implement\n");  
    return;  
}  

if 20180821

int32   cx = width;  
int32   cy = height;  

else

int32 cx = width / 10;  
int32 cy = height / 10;  
if (cx < 10) cx = 10;  
if (cy < 10) cy = 10;  

endif

if (cx > width || cy > height)  
{  
    printf("frame is too small\n");  
    return;  
}  

int32 ox = (width - cx) / 2;  
int32 oy = (height - cy) / 2;  

char* buf = new char[cx * 2 * cy];  
memset(buf, 0, cx * 2 * cy);  

int iFrame;  
for (iFrame = 0; iFrame < captransferinfo.nFrameCount; iFrame++)  
{  
    // copy image  
    copy_targetarea(hdcam, iFrame, buf, cx * 2, ox, oy, cx, cy);  

    {  
        // process image  

if OUTPUT_IMAGE

        char filename[MAX_PATH];  
        sprintf_s(filename, sizeof(filename), "output%03d.raw", iFrame);  
        output_data(filename, buf, cx * 2 * cy);  

endif

    }  
}  

delete[] buf;  

}

int main(int argc, char* const argv[])
{
printf("PROGRAM START\n");

int ret = 0;  

DCAMERR err;  

// initialize DCAM-API and open device  
HDCAM hdcam;  
hdcam = dcamcon_init_open();  
if (hdcam != NULL)  
{  
    // show device information  
    dcamcon_show_dcamdev_info(hdcam);  

    // open wait handle  
    DCAMWAIT_OPEN   waitopen;  
    memset(&waitopen, 0, sizeof(waitopen));  
    waitopen.size = sizeof(waitopen);  
    waitopen.hdcam = hdcam;  

    err = dcamwait_open(&waitopen);  
    if (failed(err))  
    {  
        dcamcon_show_dcamerr(hdcam, err, "dcamwait_open()");  
        ret = 1;  
    }  
    else  
    {  
        HDCAMWAIT hwait = waitopen.hwait;  
        if (set_binning(hdcam, BINNING_VALUE))  
        {  
            // set subarray  
            if (set_subarray(hdcam, SUBARRAY_HORZ_OFFSET, SUBARRAY_HORZ_SIZE, SUBARRAY_VERT_OFFSET, SUBARRAY_VERT_SIZE))  
            {  


                // allocate buffer  
                int32 number_of_buffer = 10;  
                err = dcambuf_alloc(hdcam, number_of_buffer);  
                if (failed(err))  
                {  
                    dcamcon_show_dcamerr(hdcam, err, "dcambuf_alloc()");  
                    ret = 1;  
                }  
                else  
                {  
                    // start capture  
                    err = dcamcap_start(hdcam, DCAMCAP_START_SEQUENCE);  
                    if (failed(err))  
                    {  
                        dcamcon_show_dcamerr(hdcam, err, "dcamcap_start()");  
                        ret = 1;  
                    }  
                    else  
                    {  
                        printf("\nStart Capture\n");  

                        // set wait param  
                        DCAMWAIT_START waitstart;  
                        memset(&waitstart, 0, sizeof(waitstart));  
                        waitstart.size = sizeof(waitstart);  
                        waitstart.eventmask = DCAMWAIT_CAPEVENT_FRAMEREADY;  
                        waitstart.timeout = 1000;  

                        // wait image  
                        err = dcamwait_start(hwait, &waitstart);  
                        if (failed(err))  
                        {  
                            dcamcon_show_dcamerr(hdcam, err, "dcamwait_start()");  
                            ret = 1;  
                        }  

                        // stop capture  
                        dcamcap_stop(hdcam);  
                        printf("Stop Capture\n");  

                        // access image  
                        printf("Access Image\n");  
                        sample_access_images(hdcam);  
                    }  

                    // release buffer  
                    dcambuf_release(hdcam);  
                }  
            }  
        }  

        // close wait handle  
        dcamwait_close(hwait);  
    }  

    // close DCAM handle  
    dcamdev_close(hdcam);  
}  
else  
{  
    ret = 1;  
}  

// finalize DCAM-API  
dcamapi_uninit();  

printf("PROGRAM END\n");  
return ret;  

}

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl dcamcon_show_dcamerr(struct tag_dcam *,enum DCAMERR,char const *,char const *,...)" (?dcamcon_show_dcamerr@@YAXPEAUtag_dcam@@W4DCAMERR@@PEBD2ZZ) referenced in function "int __cdecl copy_targetarea(struct tag_dcam *,long,void *,long,long,long,long,long)" (?copy_targetarea@@YAHPEAUtag_dcam@@JPEAXJJJJJ@Z) binned_images_ten C:\Users\bbbra\RTSM\binned_images_ten\binned_images_ten\binned_images_ten\binned_images_ten.obj 1
Error LNK2019 unresolved external symbol "struct tag_dcam * __cdecl dcamcon_init_open(void)" (?dcamcon_init_open@@YAPEAUtag_dcam@@XZ) referenced in function main binned_images_ten C:\Users\bbbra\RTSM\binned_images_ten\binned_images_ten\binned_images_ten\binned_images_ten.obj 1
Error LNK2019 unresolved external symbol "void __cdecl dcamcon_show_dcamdev_info(struct tag_dcam *)" (?dcamcon_show_dcamdev_info@@YAXPEAUtag_dcam@@@Z) referenced in function main binned_images_ten C:\Users\bbbra\RTSM\binned_images_ten\binned_images_ten\binned_images_ten\binned_images_ten.obj 1
Error LNK2019 unresolved external symbol "void __cdecl output_data(char const *,char *,long)" (?output_data@@YAXPEBDPEADJ@Z) referenced in function "void __cdecl sample_access_images(struct tag_dcam *)" (?sample_access_images@@YAXPEAUtag_dcam@@@Z) binned_images_ten C:\Users\bbbra\RTSM\binned_images_ten\binned_images_ten\binned_images_ten\binned_images_ten.obj 1
Error LNK1120 4 unresolved externals binned_images_ten C:\Users\bbbra\RTSM\binned_images_ten\binned_images_ten\binned_images_ten\x64\Debug\binned_images_ten.exe 1

I am trying to get output from a camera through a frame grabber with dcam libraries, in Visual Studio 2017, I am getting the above build errors. any help.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,571 questions
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,561 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Guido Franzke 2,196 Reputation points
    2021-02-11T11:45:58.447+00:00

    Hello,
    these are linker errors. You must add the libraries to the project.
    Regards, Guido

    1 person found this answer helpful.