Pymex compiling
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Not sure if this is the best forum to ask a question about something from the file exchange, but here I go:
I am trying to solve a mixed integer problem with Cplex, and want to use the callback functions in Python (which aren't implemented in Matlab).
Pymex (from the file exchange) looks like it could be helpful. I already have all the parameters/matrices built in Matlab, so I want to be able to automate transferring them to Python. My question:
I am not the greatest linux programmer. Pymex has this included as instructions for compiling:
Compile with: g++ pymex.cpp -o pymex.mexglx -I/opt/matlab/2009A/extern/include/ -Wl,-rpath-link,/opt/matlab/2009A/bin/glnx86 -L/opt/matlab/2009A/bin/glnx86 -lmx -lmex -lmat -lm -I/usr/include/python2.6 -I/usr/include/python2.6 -L/usr/lib/python2.6/config -lpthread -ldl -lutil -lm -lpython2.6 -rdynamic -shared
I am using Matlab 2011B. I have python 2.6. I have updated the matlab paths in the code. However, I still get a whole bunch of errors:
pymex.cpp:45:17: error: mex.h: No such file or directory
pymex.cpp:46:20: error: matrix.h: No such file or directory
pymex.cpp:48:30: error: python2.6/Python.h: No such file or directory
pymex.cpp:61: error: expected initializer before ‘*’ token
pymex.cpp:62: error: expected initializer before ‘*’ token
pymex.cpp:63: error: expected initializer before ‘*’ token
pymex.cpp:64: error: expected initializer before ‘*’ token
pymex.cpp:65: error: expected initializer before ‘*’ token
pymex.cpp:66: error: expected initializer before ‘*’ token
pymex.cpp:67: error: variable or field ‘recursive_matlab_fill’ declared void
pymex.cpp:67: error: ‘PyObject’ was not declared in this scope
pymex.cpp:67: error: ‘object’ was not declared in this scope
pymex.cpp:67: error: expected primary-expression before ‘double’
pymex.cpp:67: error: expected primary-expression before ‘const’
pymex.cpp:67: error: expected primary-expression before ‘const’
pymex.cpp:68: error: ‘PyObject’ was not declared in this scope
pymex.cpp:68: error: ‘object’ was not declared in this scope
pymex.cpp:69: error: ‘PyObject’ was not declared in this scope
pymex.cpp:69: error: ‘object’ was not declared in this scope
pymex.cpp:70: error: variable or field ‘nudge_object’ declared void
pymex.cpp:70: error: ‘PyObject’ was not declared in this scope
pymex.cpp:70: error: ‘object’ was not declared in this scope
pymex.cpp:71: error: variable or field ‘guess_dims’ declared void
pymex.cpp:71: error: ‘PyObject’ was not declared in this scope
pymex.cpp:71: error: ‘tuple’ was not declared in this scope
pymex.cpp:71: error: ‘mwSize’ was not declared in this scope
pymex.cpp:71: error: ‘num_dims’ was not declared in this scope
pymex.cpp:71: error: ‘mwSize’ was not declared in this scope
pymex.cpp:71: error: ‘dims’ was not declared in this scope
pymex.cpp:72: error: ‘PyObject’ was not declared in this scope
pymex.cpp:72: error: ‘tuple’ was not declared in this scope
pymex.cpp:72: error: expected primary-expression before ‘const’
pymex.cpp:72: error: expected primary-expression before ‘const’
pymex.cpp:72: error: initializer expression list treated as compound expression
pymex.cpp:73: error: expected initializer before ‘*’ token
pymex.cpp:153: error: ‘PyMethodDef’ does not name a type
pymex.cpp:160: error: expected initializer before ‘*’ token
pymex.cpp:164: error: expected initializer before ‘*’ token
Not really sure what to do. Help would be appreciated.
1 comentario
Kaustubha Govind
el 19 de Oct. de 2011
Do you see mex.h and matrix.h in /opt/matlab/2009A/extern/include/? Typically these files exist in $matlabroot/extern/include, where $matlabroot is the MATLAB installation directory.
Respuestas (3)
Tim Perkins
el 19 de Oct. de 2011
Hi Ed,
I would not use the command above, I would try to use the install.m script. The line in the source starting with "compile with:" was intended to be a reminder to myself while I was debugging. It is not portable.
Unfortunately the install script is also somewhat fragile. You will still need to feed it the location of the shared library, libpython2.6.so. It will probably be in /usr/lib/.
The numbers after the .so are version numbers. Typically the names without version numbers are just simlinks to the names with version numbers. Bottom line: libpython2.6.so.1.0 should be the same thing as libpython2.6.so, so it's ok to use it.
Anyway, it seems that you are missing a header. Try running this command to find the header's location:
find /usr/include/ -name Python.h
If that doesn't show anything, then you probably haven't installed the Python development packages. On Ubuntu, you will need the python-dev package:
sudo apt-get install ptyhon-dev -y
Now that I think about it, the install script should probably check for this. I'll add it to the next version.
1 comentario
Walter Roberson
el 19 de Oct. de 2011
-I/usr/include/python2.6 appears twice in the include path, but because python2.6/Python.h is being looked for, it needs -I/usr/include
Ver también
Categorías
Más información sobre Python Package Integration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!