using MySql in c++ plugins

63 views
Skip to first unread message

Rudi Hammad

unread,
May 1, 2023, 6:11:52 AM5/1/23
to Python Programming for Autodesk Maya
hello,
first of all, let me know if this is out the scope of this forum to post it somewhere else.
I post it here because it is related to maya anyways and might also be valid for the python api.

Anyways, I want to connect my maya plugins to my data base. I did that already creating an empty windows projects and everything work as expected. The connection was successful.
Here is the working code:
(of course set the sensible data as "xxxxx")

For this to work I set visual studio as follows:
- C/C++ | General | addition include directories -> C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc
- C/C++ | prepocessor | preprocessor Definitions add STATIC_CONCPP
- C/C++ | Code Generatin| Runtime library -> Multi-threaded DLL (/MD)
- Linker | General | additional library directories -> add C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14
- Linker | Input | additional dependencies -> add mysqlcppconn-static.lib


So then I went to a working Maya Plugin I wrote and tried to add that same code, adding to the existing visual studio setup the paths above. And I gave me an error when it runs: get_driver_instance();
Here  is the error

1>mysqlcppconn-static.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp_RegCloseKey
1>mysqlcppconn-static.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp_RegEnumValueA
1>mysqlcppconn-static.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp_RegOpenKeyExA
1>mysqlcppconn-static.lib(common.obj) : error LNK2001: unresolved external symbol __imp_EqualSid
1>mysqlcppconn-static.lib(common.obj) : error LNK2001: unresolved external symbol __imp_GetTokenInformation
1>mysqlcppconn-static.lib(common.obj) : error LNK2001: unresolved external symbol __imp_IsValidSid
1>mysqlcppconn-static.lib(common.obj) : error LNK2001: unresolved external symbol __imp_LookupAccountNameW

I have been googling to solve this, but linking errors are a bit advanced for me to know exactly what is wrong. I looked into this forum about mysql topics but didn't find an answer to setup maya and mysql. And I only found in the maya docs this :


My guess is that it must be some specific version that works with maya (the doc mentions MySQL 5.0.27) but I think it must be more complicated that.
So before breaking my visual studio setup I prefered to ask here, even though I am aware it might be a bit of an advanced topic.

Anyway, please let me know what you think.
Thx,

R

Rudi Hammad

unread,
May 2, 2023, 8:37:53 AM5/2/23
to Python Programming for Autodesk Maya
I king of solved the error by usng mysqlcppconn.lib  instead of mysqlcppconn-static.lib .
With this the plugin compiled OK, but when l load it in maya a get a Dynamic load error.
Anyways, I ended up using MySql in python which is a lot easier, but it would be cool to trying to run mysql directly in C++ in a maya plugin.

Cheers
Reply all
Reply to author
Forward
0 new messages