3

I wrote a C++ application inclunding the external libraries glpk and boost with a binding to the Matlab API. On Ubuntu compiling in Matlab using mex works fine, the program is running without difficulties.

Now to use the same application on a Windows Platform I wanted to cross-compile it, using Mingw64. Corresponding to this thread it can be done with 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
  • Path /usr/local/include contains the header files for the boost library (header only library)
  • Path /usr/include contains the header files for the glpk library
  • Path /usr/lib contains the source files for the glpk library

But running this command gives me the error that there are conflicting declarations of the type:

/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 causes problem for the compiler. But it is needed to include the glpk header files. Any ideas to solve the problem?

Community
  • 1
  • 1
Reza
  • 360
  • 3
  • 17

1 Answers1

0

If your glpk headers are in /usr/include, chances are you didn't compile the library for Windows. You should cross-compile all libraries for the target platform (and install them in /usr/x86_64-w64-mingw32 (if I deduce your installation details correctly).

One big gotcha you're not going to be able to solve: your Matlab is Linux, and doesn't contain any Windows linkable libraries, so you're out of luck anyways.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • I've now installed [cygwin](http://www.cygwin.com) on a windows machine to use the Matlab's dll's. But now I get errors of the form: `error: '::strtold' has not been declared` – Reza May 02 '12 at 12:32
  • You don't need Cygwin to run Matlab nor MinGW binaries. The Microsoft C runtime does not have `strtold`. – rubenvb May 02 '12 at 12:39