why do I get an error message using template?

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default why do I get an error message using template?

    I'm using CW7.0 on the Mac. I got an error when I compiled the code
    which copied from a windows C++ project. The following are related
    subroutines. I can't send the whole one for it's too long.
    Do you have any suggestion? Thanks!
    Dion

    ___________________________________
    Link error: undefined ‘_cut_fp2unsigned' (code)
    Reference from ‘_get_numeric <UL> (const mxArray_tag*,
    unsigned long*)' in square_mexFunction.cp
    ___________________________________

    //square_mexFunction.cp
    ………………..
    ………………..
    // Load up an array (which may consist only of a single element) with
    // the values from a matlab object. Arguments:
    // 1) The matlab object.
    // 2) Where to put the values. The array should be allocated
    sufficiently
    // large so that all of the values in the matlab object can be
    converted.
    // These functions return 0 on error, or 1 if the operation succeded.
    //
    template <class FLOAT>
    static int
    _get_numeric(const mxArray *mat, FLOAT *arr) // float or double.
    {
    int idx;
    int n_elements = _arraylen(mat); // Get the length.

    if (mxIsDouble(mat)) // Ordinary double precision matrix?
    {
    double *pr = mxGetPr(mat); // Point to vector of double precision
    values.

    for (idx = 0; idx < n_elements; ++idx) // Loop through all
    elements.
    *arr++ = (FLOAT)*pr++; // Convert and copy this element.
    }
    else // Don't know what this is.
    return 0; // Type conversion error.

    return 1; // No error.
    }
    …………………
    …………………
    void _wrap_GPCTR_Change_Parameter(int nlhs, mxArray **plhs, int nrhs,
    const mxArray **prhs)
    {
    if (nlhs > 1 ||
    nrhs != 4+1)
    mexErrMsgTxt("Wrong number of arguments to function
    GPCTR_Change_Parameter");
    int _d[4] = { 1,1,1,1 };
    int _vec_n = 0;
    int _vidx;
    int _vec_sz;
    short *_arg_deviceNumber;
    unsigned long *_arg_gpCounterNumber;
    unsigned long *_arg_paramID;
    unsigned long *_arg_paramValue;
    short *_arg_retval;
    int _vecstride_deviceNumber = 1;
    int _vecstride_gpCounterNumber = 1;
    int _vecstride_paramID = 1;
    int _vecstride_paramValue = 1;
    if (!_check_input_vectorize(prhs[1], &_vec_n, _d, 0,
    &_vecstride_deviceNumber))
    mexErrMsgTxt("Error in dimension of argument deviceNumber");
    if (mxIsInt16(prhs[1]) || mxIsUint16(prhs[1]))
    _arg_deviceNumber = (short *)mxGetData(prhs[1]);
    else
    {
    _arg_deviceNumber = MEM_ALLOC(short *, _arraylen(prhs[1]), sizeof
    (short));
    if (!_get_numeric(prhs[1], _arg_deviceNumber))
    mexErrMsgTxt("Expecting numeric matrix for argument
    deviceNumber");
    }

    if (!_check_input_vectorize(prhs[2], &_vec_n, _d, 0,
    &_vecstride_gpCounterNumber))
    mexErrMsgTxt("Error in dimension of argument gpCounterNumber");
    if (mxIsInt32(prhs[2]) || mxIsUint32(prhs[2]))
    _arg_gpCounterNumber = (unsigned long *)mxGetData(prhs[2]);
    else
    {
    _arg_gpCounterNumber = MEM_ALLOC(unsigned long *,
    _arraylen(prhs[2]), sizeof (unsigned long));
    if (!_get_numeric(prhs[2], _arg_gpCounterNumber))
    mexErrMsgTxt("Expecting numeric matrix for argument
    gpCounterNumber");
    }

    if (!_check_input_vectorize(prhs[3], &_vec_n, _d, 0,
    &_vecstride_paramID))
    mexErrMsgTxt("Error in dimension of argument paramID");
    if (mxIsInt32(prhs[3]) || mxIsUint32(prhs[3]))
    _arg_paramID = (unsigned long *)mxGetData(prhs[3]);
    else
    {
    _arg_paramID = MEM_ALLOC(unsigned long *, _arraylen(prhs[3]),
    sizeof (unsigned long));
    if (!_get_numeric(prhs[3], _arg_paramID))
    mexErrMsgTxt("Expecting numeric matrix for argument paramID");
    }

    if (!_check_input_vectorize(prhs[4], &_vec_n, _d, 0,
    &_vecstride_paramValue))
    mexErrMsgTxt("Error in dimension of argument paramValue");
    if (mxIsInt32(prhs[4]) || mxIsUint32(prhs[4]))
    _arg_paramValue = (unsigned long *)mxGetData(prhs[4]);
    else
    {
    _arg_paramValue = MEM_ALLOC(unsigned long *, _arraylen(prhs[4]),
    sizeof (unsigned long));
    if (!_get_numeric(prhs[4], _arg_paramValue))
    mexErrMsgTxt("Expecting numeric matrix for argument
    paramValue");
    }

    {
    int _ds[] = { _d[0] , _d[1] , _d[2] , _d[3] };
    plhs[0] = mxCreateNumericArray(max((0 + _vec_n), 2), _ds,
    mxDOUBLE_CLASS, mxREAL);
    _arg_retval = MEM_ALLOC(short *, _arraylen(plhs[0]), sizeof
    (short));
    }
    _vec_sz = _d[0]*_d[1]*_d[2]*_d[3];
    for (_vidx = 0; _vidx < _vec_sz; ++_vidx) {
    _arg_retval[_vidx] = (short)
    GPCTR_Change_Parameter(_arg_deviceNumber[_vecstride_deviceNumber*_vidx],
    _arg_gpCounterNumber[_vecstride_gpCounterNumber*_vidx],
    _arg_paramID[_vecstride_paramID*_vidx],
    _arg_paramValue[_vecstride_paramValue*_vidx]);
    }
    {
    int _fidx;
    double *d_ptr = mxGetPr(plhs[0]);
    for (_fidx = 0; _fidx < _arraylen(plhs[0]); ++_fidx)
    *d_ptr++ = (double)*_arg_retval++;
    }
    }
    ……………………
    ……………………
    Deyue Yu Guest

  2. Similar Questions and Discussions

    1. How To Supress Acrobat Error Message And Alert Message
      Is there any way to supress those pop up message? If can't, is there any way to catch it?
    2. Error Message When Sending Message In Windows Mail
      Am I the only one getting an error message when replying to a posted message using Windows Mail. Every time I send a message I get a popup error...
    3. Template error code 3 + Error Accessing files..
      Hi, I am really out of any idea after searching Macromedia website and still cant find the solution. I faced the error code 3 when trying to update...
    4. Template Error Message
      hi, I am wondering if anyone can help me. Some else has designed the website that i am now in charge of updating and editing. i have made some...
    5. Error message when updating template
      Hi...I've created a template that I use to update several pages on a website. When I make changes to the template...and save it, I'm asked if I want...
  3. #2

    Default Re: why do I get an error message using template?

    In article <442f5600.0307020801.1e28840a@posting.google.com >,
    [email]dionyue@msn.com[/email] (Deyue Yu) wrote:
    >I'm using CW7.0 on the Mac. I got an error when I compiled the code
    >which copied from a windows C++ project. The following are related
    >subroutines. I can't send the whole one for it's too long.
    >Do you have any suggestion? Thanks!
    >___________________________________
    >Link error: undefined ‘_cut_fp2unsigned' (code)
    > Reference from ‘_get_numeric <UL> (const mxArray_tag*,
    >unsigned long*)' in square_mexFunction.cp
    >___________________________________
    Linker errors for undefined items, are where you don't have the function
    defined. For example if you have mxGetPr in a header file it will
    compile but if you have this function in a C source file or forgot to
    add that file to your project (or that library to the project) you will
    get a linker undefined error.

    Check to be sure you have the file in a C++ file. It is easy to have
    force C++ enabled in one and not in another and get these type of
    undefined linker errors.

    Bottome line is that the actual code is missing or misnamed for _cut_

    Ron
    >
    >//square_mexFunction.cp
    >………………..
    >………………..
    >// Load up an array (which may consist only of a single element) with
    >// the values from a matlab object. Arguments:
    >// 1) The matlab object.
    >// 2) Where to put the values. The array should be allocated
    >sufficiently
    >// large so that all of the values in the matlab object can be
    >converted.
    >// These functions return 0 on error, or 1 if the operation succeded.
    >//
    >template <class FLOAT>
    >static int
    >_get_numeric(const mxArray *mat, FLOAT *arr) // float or double.
    >{
    > int idx;
    > int n_elements = _arraylen(mat); // Get the length.
    >
    > if (mxIsDouble(mat)) // Ordinary double precision matrix?
    > {
    > double *pr = mxGetPr(mat); // Point to vector of double precision
    >values.
    >
    > for (idx = 0; idx < n_elements; ++idx) // Loop through all
    >elements.
    > *arr++ = (FLOAT)*pr++; // Convert and copy this element.
    > }
    > else // Don't know what this is.
    > return 0; // Type conversion error.
    >
    > return 1; // No error.
    >}
    --
    Metrowerks has moved, our new address is now
    7700 West Parmer Lane
    Austin, TX 78729
    Sales and Support 512-996-5300 800-377-5416
    Ron Liechty - [email]MWRon@metrowerks.com[/email] - [url]http://www.metrowerks.com[/url]
    MW Ron Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139