Problems cross-compiling oct Matlab file using Mingw64 on Ubuntu

I wrote a C ++ application that included glpk and boost external libraries with a binding to the Matlab API. In Ubuntu, compiling in Matlab using mex works fine, the program works without problems.

Now, to use the same application on a Windows platform, I would like to cross-compile it using Mingw64. According to this thread, this can be done using the following command:

x86_64-w64-mingw32-gcc -m64 -shared -I"/usr/local/MATLAB/R2011a/extern/include" -I"/usr/local/include" -I"/usr/include" -DMATLAB_MEX_FILE -o output.mexw64 input.cpp -L"/usr/local/MATLAB/R2011a/bin/glnxa64/" -lmex -lmx -lmat -leng -L"/usr/lib" -lglpk
  • The path / usr / local / include contains header files for the boost library (only for the header library)
  • The path / usr / include contains the header files for the glpk library.
  • The path / usr / lib contains the source files for the glpk library.

But the execution of this command gives me an error, which is conflicting declarationslike:

/usr/include/sys/types.h:110:19: error: conflicting declaration ‘typedef __ssize_t ssize_t
/usr/lib/gcc/x86_64-w64-mingw32/4.6/../../../../x86_64-w64-mingw32/include/_mingw.h:394:35: error: ‘ssize_t’ has a previous declaration as ‘typedef long long int ssize_t

It seems that the path / usr / include is causing a problem for the compiler. But you need to include glpk header files. Any ideas to solve the problem?

+3
source share
1 answer

If your glpk headers are located in / usr / include, most likely you did not compile the library for Windows. You must cross-compile all the libraries for the target platform (and install them in / usr / x 86_64-w64-mingw32 (if I list your installation information correctly).

One big question that you cannot solve: your Matlab is Linux and does not contain any Windows-compatible libraries, so you are out of luck anyway.

0
source

All Articles