Errors compiling mex file with c++ and mysql in R2016b

2 views (last 30 days)
Marina Frants
Marina Frants on 24 Sep 2021
Answered: Swatantra Mahato on 7 Oct 2021
I've been given some Matlab code for R2016b and a .cpp file to go with it, and I'm trying to compile it on Windows10 with the MinGW64 C++ compiler. My mex command is:
mex('<my script>', '-v', ['-I' inclib], ['-L' linklib], '-lmysqlclient')
Where inclib='C:\Program Files\MySQL\MySQL Server 8.0\include' and linklib='C:\Program Files\MySQL\MySQL Server 8.0\lib'
This starts of with a bunch of warnings:
Warning: corrupt .drectve at end of def file
followed by a huge dump of error messages:
C:\Program Files\MySQL\MySQL Server 8.0\lib/mysqlclient.lib(C:/build/sb_1-3692420-1625128314.67/release/libmysql/clientlib_objlib.dir/RelWithDebInfo/client_plugin.obj):(.text$mn+0x175): undefined reference to __security_check_cookie' C:\Program Files\MySQL\MySQL Server 8.0\lib/mysqlclient.lib(C:/build/sb_1-3692420-1625128314.67/release/libmysql/clientlib_objlib.dir/RelWithDebInfo/client_plugin.obj):(.text$mn+0x1cf): undefined reference to __security_check_cookie' C:\Program Files\MySQL\MySQL Server 8.0\lib/mysqlclient.lib(C:/build/sb_1-3692420-1625128314.67/release/libmysql/clientlib_objlib.dir/RelWithDebInfo/client_plugin.obj):(.text$mn+0x3c2): undefined reference to __security_check_cookie' C:\Program Files\MySQL\MySQL Server 8.0\lib/mysqlclient.lib(C:/build/sb_1-3692420-1625128314.67/release/libmysql/clientlib_objlib.dir/RelWithDebInfo/client_plugin.obj):(.xdata[$unwind$mysql_load_plugin_v]+0x14): undefined reference to __GSHandlerCheck' C:\Program Files\MySQL\MySQL Server 8.0\lib/mysqlclient.lib(C:/build/sb_1-3692420-1625128314.67/release/libmysql/clientlib_objlib.dir/RelWithDebInfo/client_plugin.obj):(.xdata[$unwind$mysql_client_plugin_init]+0x8): undefined reference to __GSHandlerCheck'
And so on and so forth, with these errors being repeated over and over
Are there some libraries that I'm missings, or settings I need to change? I'm new to both Windows and C++, so I'm not really sure where to start.

Answers (1)

Swatantra Mahato
Swatantra Mahato on 7 Oct 2021
Hi Marina,
From my understanding of the initial warning and the following error messages, this looks like an issue caused by using the "MinGW" compiler to compile files which require libraries from the "Microsoft Visual C++" compiler.
You may want to switch the C++ compiler to an appropriate version of MSVC for R2016b to link the required libraries correctly. You can find the list of supported compilers from the below link
Hope this helps

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!