Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2 amd64 compilation problem

open
nobody
5
2006-04-21
2006-04-21
Anonymous
No

Hi,

When I try to compile mlabraw.cpp, I receive the
following error message:

mlabraw.cpp:515: error: cast from ‘Engine*’ to ‘int’
loses precision

I assume this is related to the fact that I try to
compile mlabraw with gcc version 4 on a 64bit computer
(FC4, Python 2.4.3)

Is there any fix??????

thanks

--
mathieu

Discussion

  • Logged In: NO

    Here is a patch to make it with amd64. The bug is resolved
    by using long int instead of int for the Engine pointer.

    I also had a problem with the xrange(sys.maxint), so I
    arbitrarily changed it to xrange(100) in the patch. I think
    this is a 64 bit python problem.

    To apply the patch:
    to patch

    cd to mlabwrap-0.9.1
    patch -p1 < ../amd64.patch

     
  • Logged In: NO

    amd64.patch

    diff -u -r -N mlabwrap-0.9.1/mlabraw.cpp
    mlabwrap-0.9.1_amd64/mlabraw.cpp
    --- mlabwrap-0.9.1/mlabraw.cpp 2003-11-29
    17:40:26.000000000 -0500
    +++ mlabwrap-0.9.1_amd64/mlabraw.cpp 2006-09-06
    13:31:16.000000000 -0400
    @@ -499,7 +499,7 @@
    char *lStr = "\0"; // "matlab -check_malloc";
    if (! PyArg_ParseTuple(args, "|s:open", &lStr)) return NULL;

    - pyassert(sizeof(int) >= sizeof(Engine *),
    + pyassert(sizeof(long int) >= sizeof(Engine *),
    "Oops! Pointers on this architecture are too big
    to fit in integers");
    #ifdef WIN32
    @@ -512,7 +512,7 @@
    return NULL;
    }

    - return Py_BuildValue("i", int(ep));
    + return Py_BuildValue("l", (long int)(ep));

    error_return:
    return NULL;
    @@ -528,9 +528,9 @@
    ;
    PyObject * mlabraw_close(PyObject *, PyObject *args)
    {
    - int lHandle;
    + long int lHandle;

    - if (! PyArg_ParseTuple(args, "i:close", &lHandle)) return
    NULL;
    + if (! PyArg_ParseTuple(args, "l:close", &lHandle)) return
    NULL;

    if (engClose((Engine *)lHandle) != 0) {
    PyErr_SetString(mlabraw_error, "Unable to close session");
    @@ -562,8 +562,8 @@
    char *lStr;
    char *retStr = buffer;
    PyObject *ret;
    - int lHandle;
    - if (! PyArg_ParseTuple(args, "is:eval", &lHandle, &lStr))
    return NULL;
    + long int lHandle;
    + if (! PyArg_ParseTuple(args, "ls:eval", &lHandle, &lStr))
    return NULL;
    engOutputBuffer((Engine *)lHandle, retStr, BUFSIZE-1);
    if (engEvalString((Engine *)lHandle, lStr) != 0) {
    PyErr_SetString(mlabraw_error,
    @@ -612,11 +612,11 @@
    PyObject * mlabraw_get(PyObject *, PyObject *args)
    {
    char *lName;
    - int lHandle;
    + long int lHandle;
    mxArray *lArray = NULL;
    PyObject *lDest = NULL;

    - if (! PyArg_ParseTuple(args, "is:get", &lHandle, &lName))
    return NULL;
    + if (! PyArg_ParseTuple(args, "ls:get", &lHandle, &lName))
    return NULL;

    // for matlab >= 6.5 (FIXME UNTESTED)
    #ifdef _V6_5_OR_LATER
    @@ -662,11 +662,11 @@
    PyObject * mlabraw_put(PyObject *, PyObject *args)
    {
    char *lName;
    - int lHandle;
    + long int lHandle;
    PyObject *lSource;
    mxArray *lArray = NULL;

    - if (! PyArg_ParseTuple(args, "isO:put", &lHandle, &lName,
    &lSource)) return NULL;
    + if (! PyArg_ParseTuple(args, "lsO:put", &lHandle, &lName,
    &lSource)) return NULL;
    Py_INCREF(lSource);

    if (PyString_Check(lSource)) {
    diff -u -r -N mlabwrap-0.9.1/mlabwrap.py
    mlabwrap-0.9.1_amd64/mlabwrap.py
    --- mlabwrap-0.9.1/mlabwrap.py 2005-05-03
    16:11:47.000000000 -0400
    +++ mlabwrap-0.9.1_amd64/mlabwrap.py 2006-09-06
    13:44:19.000000000 -0400
    @@ -489,7 +489,7 @@
    argnames = []
    tempargs = []
    try:
    - for arg, count in zip(args, xrange(sys.maxint)):
    + for arg, count in zip(args, xrange(100)):
    if isinstance(arg, MlabObjectProxy):
    argnames.append(arg._name)
    else:
    diff -u -r -N mlabwrap-0.9.1/setup.py
    mlabwrap-0.9.1_amd64/setup.py
    --- mlabwrap-0.9.1/setup.py 2005-05-03
    16:11:47.000000000 -0400
    +++ mlabwrap-0.9.1_amd64/setup.py 2006-09-06
    10:25:52.000000000 -0400
    @@ -11,9 +11,9 @@
    ##### (if setup.py fails to guess the right values for
    them) #####
    ####################################################################
    MATLAB_VERSION = 7 # e.g: 6 (one of (6, 6.5, 7))
    -MATLAB_DIR=None # e.g: '/usr/local/matlab';
    'c:/matlab6'
    +MATLAB_DIR='/usr/local/matlabR2006a' # e.g:
    '/usr/local/matlab'; 'c:/matlab6'
    EXTRA_COMPILE_ARGS=None # e.g: ['-G']
    -PLATFORM_DIR=None # e.g: 'glnx86';
    r'win32/microsoft/msvc60'
    +PLATFORM_DIR='glnxa64' # e.g: 'glnx86';
    r'win32/microsoft/msvc60'

    # hopefully these 3 won't need modification
    MATLAB_LIBRARIES=None # e.g: ['eng', 'mx', 'mat',
    'mi', 'ut']

     
  • Joe Lingevitch
    Joe Lingevitch
    2006-09-07

    Logged In: YES
    user_id=1592921

    Here is a patch to make it with amd64. The bug is resolved
    by using long int instead of int for the Engine pointer.

    I also had a problem with the xrange(sys.maxint), so I
    arbitrarily changed it to xrange(100) in the patch. I think
    this is a 64 bit python problem.

    To apply the patch:
    to patch

    cd to mlabwrap-0.9.1
    patch -p1 < ../amd64.patch