Problems compiling on Windows

Jim T
  • Jim T

    Jim T - 2010-08-11


    I'm having trouble compiling MyM 1.36 and 1.09 on Windows, both WinXP (32) and Windows 7.
    The Windows 7 computer is the biggest problem, as I have no binary for this - the other ones I can continue using, with version 1.0.9.

    I have downloaded MySQL 5.1.49 today, as well as zlib 125. Apparently, there are no dependency issues.

    On Windows 7, the following happens: (Using matlab r2010a, Visual Studio 2010)
    Matlab input:

    mex -v -IH:\mysql-5.1.49-winx64\include -IH:\zlib125-dll\include -LH:\mysql-5.1.49-winx64\lib -LH:\zlib125-dll\lib -lz -lmysqlclient mym.cpp

    matlab output:

     This is mex, Copyright 1984-2007 The MathWorks, Inc.
    -> Default options filename found in D:\Users\miggland\AppData\Roaming\MathWorks\MATLAB\R2010a 
    ->    Options file           = D:\Users\miggland\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat 
          MATLAB                 = C:\PROGRA~1\MATLAB 
    ->    COMPILER               = cl 
    ->    Compiler flags: 
             OPTIMFLAGS          = /O2 /Oy- /DNDEBUG 
             DEBUGFLAGS          = /Z7 
             arguments           =  -IH:\MYSQL-~2.49-\INCLUDE -IH:\ZLIB12~1\INCLUDE 
             Name switch         = /Fo 
    ->    Pre-linking commands   =  
    ->    LINKER                 = link 
    ->    Link directives: 
             LINKFLAGS           = /dll /export:mexFunction /LIBPATH:"C:\PROGRA~1\MATLAB\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"D:\USERS\MIGGLAND\APPDATA\LOCAL\TEMP\MEX_QC~1\templib.x" /MAP:"" 
             LINKDEBUGFLAGS      = /debug /PDB:"mym.mexw64.pdb" 
             LINKFLAGSPOST       =  
             Name directive      = /out:"mym.mexw64" 
             File link directive =  
             Lib. link directive =  
             Rsp file indicator  = @ 
    ->    Resource Compiler      = rc /fo "mexversion.res" 
    ->    Resource Linker        =  
    c:\program files\matlab\extern\include\matrix.h(330) : error C2371: 'char16_t' : redefinition; different basic types 
            C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576) : see declaration of 'char16_t' 
    mym.cpp(250) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data 
    mym.cpp(806) : warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data 
    mym.cpp(893) : warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data 
    mym.cpp(963) : warning C4267: '=' : conversion from 'size_t' to 'ulong', possible loss of data 
    mym.cpp(965) : warning C4267: '=' : conversion from 'size_t' to 'ulong', possible loss of data 
    mym.cpp(1087) : warning C4267: '=' : conversion from 'size_t' to 'ulong', possible loss of data
      C:\PROGRA~1\MATLAB\BIN\MEX.PL: Error: Compile of 'mym.cpp' failed.
    ??? Error using ==> mex at 222
    Unable to complete successfully.

    Thanks in advance for any help. I would also appreciate it if someone would simply make a 64bit windows binary available for the program.

  • Anonymous - 2011-01-05

    I had the same issue using Microsoft Visual C++ 2010 express edition, but the code can be compiled using Microsoft Visual C++ 2008 express edition.

  • Anonymous - 2011-01-11

    mex -I".\zlib125-dll\include" -I"C:\Program Files\MySQL\MySQL Server 5.5\include" -L".\zlib125-dll\lib" -L"C:\Program Files\MySQL\MySQL Server 5.5\lib" -lzdll -lmysqlclient ".\mym_src_v1.36\mym_src_v1.36\mym.cpp" LINKFLAGS="$LINKFLAGS /NODEFAULTLIB:LIBCMT"

    This worked with the following:
    -Windows 7 64-bit
    -Matlab 2010a 64-bit
    -MySQL 5.5
    -Visual Studio Pro Trial 2010
    (Matlab 2010a needs some mexopts for VS2010 but they are freely available from the matlab website).

    However, this does not work with
    -Windows 7 32-bit
    -Matlab 2010b 32-bit
    -MySQL 5.5
    -Visual Studio Pro Trial 2010.

    Unfortunately I uninstalled VS2010 before I could copy-paste the error messages but it had something to do with missing external compression something-or-other.

    I will update after I try the 32-bit setup with VS 2008 express.

  • Anonymous - 2011-01-11

    Same error with VS 2008 express.

    Creating library C:\Users\Chad\AppData\Local\Temp\mex_raVla0\templib.x and object C:\Users\Chad\AppData\Local\Temp\mex_raVla0\templib.exp 
    mym.obj : error LNK2019: unresolved external symbol _uncompress@16 referenced in function "struct mxArray_tag * __cdecl deserialize(char const *,unsigned long)" (?deserialize@@YAPAUmxArray_tag@@PBDK@Z) 
    mym.obj : error LNK2019: unresolved external symbol _compress@16 referenced in function _mexFunction 
    mym.obj : error LNK2019: unresolved external symbol _compressBound@4 referenced in function _mexFunction 
    mym.mexw32 : fatal error LNK1120: 3 unresolved externals
      C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'mym.mexw32' failed.
  • Justace Clutter

    Justace Clutter - 2011-02-17

    I am currently using MinGW (the latest stable release) and Matlab 2010a.  I have installed the MySQL Server 5.5 binaries for windows and now want to get this tool working though Matlab.  I have tried to compile it but I keep getting, no matter what I do, the same errors as above.  The seemingly unresolved symbols with libz.  I have tried to find some solutions but I can not find a good answer.  The version of libz that I installed is 1.2.3 (I think).  Does anybody know what the issue with the unresolved libz references is?  Any and all help is appreciated.  I would give more info but I am at home now and not close to my computer at work.  Thanks in advance.

  • Anonymous - 2011-09-12

    Has anyone had recent success in compiling mym?  I have had the same problems as 1 and 4 and have tried both visual studio 2008 and 2010.
    I am running windows xp, other than that i have the same configurations as jimttt.

  • Matt

    Matt - 2012-07-18

    I just struggled for several hours with the same issue as above (comment 4), and finally got it to work.  I have matlab r2010b, Windows 7 32 bit, and visual studio 2010.  The problem seems to be something in zlib.lib in the MySQL directory.  If you replace the "-lz" or "-lzlib" with "-lzlibwapi" (and point to zlib125dll as library location) it should work.

    So my final command is:
    mex -I'C:\Program Files\MySQL\Connector C 6.0.2\include' -I'C:\zlib-1.2.7' -L'C:\Program Files\MySQL\MySQL Server 5.5\lib' -L'C:\Program Files\MySQL\Connector C 6.0.2\lib\opt' -L'C:\zlib125dll\dll32' -lmysqlclient -lzlibwapi mym.cpp

    I then also had to copy zlibwapi.dll and libmysql.dll to C:\system32 in order to run mym once compiled.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks