Clear Filters
Clear Filters

Building mym on 64-bit Windows 7

7 views (last 30 days)
Otis on 10 Apr 2012
Answered: Matthias on 1 Aug 2017
Has anyone been able to get mym ( ) to build on a 64-bit Win7 machine? And if so would you mind posting or linking your steps to do so?
My particulars:
Windows 7 Enterprise, 64-bit OS
MATLAB Version (R2011b)
Microsoft VS 2010 Ver. 10.0.30319.1
MySQL Ver 14.14 Distrib 5.5.21, for Win64 (x86)
I ran "mex -setup" and I was able to compile and run "yprime.c"
I downloaded and installed zlib ( ), which is what the readme file for mym says to do.
Here is the mex command that I am using:
mex -IC:\zlib-1.2.6 -I'C:\Program Files\MySQL\Connector C 6.0.2\include' ...
-L'C:\Program Files\MySQL\Connector C 6.0.2\lib\opt' ...
-L'C:\zlib-1.2.6' -lzlib -lmysqlclient mym.cpp
I get a bunch of "already defined in MSVCRT.lib" error messages. e.g.:
LIBCMT.lib(tidtable.obj) : error LNK2005: _encoded_null already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(invarg.obj) : error LNK2005: _set_invalid_parameter_handler already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _initterm_e already defined in MSVCRT.lib(MSVCR100.dll)
I admit that I'm stumped at this point and there is not a whole lot of helpful info out there on the world wide web. Any suggestions would be greatly, and I mean greatly, appreciated.
Thanks, Bill

Accepted Answer

William on 20 Sep 2012
Finally got this stupid ** to work. Add COMPFLAGS="$COMPFLAGS /MT" to your command. So it should look something like:
mex -v COMPFLAGS="$COMPFLAGS /MT" -I"C:\zlib-1.2.6" -I"C:\Program Files\MySQL\Connector C 6.0.2\include" -L"C:\Program Files\MySQL\Connector C 6.0.2\lib\opt" -L"C:\zlib-1.2.6" -lzlib -lmysqlclient mym.cpp
Or, in my case:
mex -v COMPFLAGS="$COMPFLAGS /MT" -I"C:\Program Files\MySQL\MySQL Server 5.5\include" -I"C:\Program Files\zlib-1.2.7" -L"C:\Program Files\MySQL\MySQL Server 5.5\lib" -L"C:\Program Files\zlib-1.2.7" -lz -lmysqlclient mym.cpp

More Answers (2)

Karl on 20 Sep 2012
Thanks, this was very helpful!
A couple notes:
- I had to use '-lzlib' instead of '-lz'
- Here's a discussion of the /MT switch (it causes your app to use static version of runtime library)
- I had to build zlib from source. Here's how
  1. Download from here:
  2. Start...All Programs...Microsoft Visual Studio 2010...Visual Studio Tools...Visual Studio 2010 Command Prompt
  3. Wait for several minutes till it finishes updating environment.
  4. cd C:\zlib-1.2.7
  5. nmake -f win32/Makefile.msc

Matthias on 1 Aug 2017
Thanks. I got it to work, but had to remove the
So the overall command:
mex -v -I"C:\Program Files\MySQL\MySQL Server 5.7\include" -I"T:\zlib-1.2.11" -L"C:\Program Files\MySQL\MySQL Server 5.7\lib" -L"T:\zlib-1.2.11" -lzlib -lmysqlclient mym.cpp

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!