Build AMXX and mysql module on Visual Studio 2015 with Mozilla Build
I got the following problem:
PHP Code:
[8388] cl basic_sql.obj handles.obj module.obj threading.obj _public_sdk_amxxmodule.obj oldcompat_sql.obj thread_BaseWorker.obj thread_ThreadWorker.obj mysql_MysqlQuery.obj mysql_MysqlRe
sultSet.obj mysql_MysqlDatabase.obj mysql_MysqlDriver.obj thread_WinThreads.obj version.res /link /MACHINE:X86 /SUBSYSTEM:WINDOWS kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.
lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\support\versionlib\version\version.lib d:\User\Dropbox\Applications\SoftwareVersioning\Allie
dModdersFiles\Dependencies\mysql-5.0\lib\opt\mysqlclient.lib ws2_32.lib ..\..\..\third_party\zlib\zlib\zlib.lib /OUT:mysql_amxx.dll /DEBUG /nologo /DLL /DEBUG /PDB:"mysql_amxx.pdb"
Creating library mysql_amxx.lib and object mysql_amxx.exp
mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(vio.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(ctype.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(xml.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(password.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(my_time.obj) : error LNK2001: unresolved external symbol _sprintf
mysqlclient.lib(my_open.obj) : error LNK2019: unresolved external symbol __dosmaperr referenced in function _my_sopen
mysqlclient.lib(default.obj) : error LNK2019: unresolved external symbol _printf referenced in function _load_defaults
mysql_amxx.dll : fatal error LNK1120: 3 unresolved externals
Build failed.
I researched for solutions and I found these references:
- AlliedModders - Extension compiler: unresolved external symbol __snwprintf
- AlliedModders - How do you build SourceMod extension on Windows?
- StackOverflow - C++: Unresolved external symbol _sprintf and _sscanf in Visual Studio 2015
Code:
Add the following library to the linker input files:
legacy_stdio_definitions.lib
VS 2015 now uses inline definitions that call internal functions for many of the `stdio.h` functions.
If an object file (or library member) depends on one of those functions, then the
`legacy_stdio_definitions.lib` provides an externally linkable version of the function
that can be linked to.
I said good, but where are the `linker input files` for the mysql module on the AM Build Script?
I think I found it on:
PHP Code:
File: amxmodx\modules\mysqlx\AMBuilder
25: elif builder.target_platform is 'windows':
26: binary.compiler.linkflags += [
27: os.path.join(AMXX.mysql_path, 'lib', 'opt', 'mysqlclient.lib'),
28: 'ws2_32.lib','legacy_stdio_definitions.lib'
29: ]
However after I added it I got new error:
PHP Code:
[29660] cl basic_sql.obj handles.obj module.obj threading.obj _public_sdk_amxxmodule.obj oldcompat_sql.obj thread_BaseWorker.obj thread_ThreadWorker.obj mysql_MysqlQuery.obj mysql_MysqlR
esultSet.obj mysql_MysqlDatabase.obj mysql_MysqlDriver.obj thread_WinThreads.obj version.res /link /MACHINE:X86 /SUBSYSTEM:WINDOWS kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32
.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\support\versionlib\version\version.lib d:\User\Dropbox\Applications\SoftwareVersioning\Alli
edModdersFiles\Dependencies\mysql-5.0\lib\opt\mysqlclient.lib ws2_32.lib legacy_stdio_definitions.lib ws2_32.lib ..\..\..\third_party\zlib\zlib\zlib.lib /OUT:mysql_amxx.dll /DEBUG /nolog
o /DLL /DEBUG /PDB:"mysql_amxx.pdb"
Creating library mysql_amxx.lib and object mysql_amxx.exp
mysqlclient.lib(my_open.obj) : error LNK2019: unresolved external symbol __dosmaperr referenced in function _my_sopen
mysql_amxx.dll : fatal error LNK1120: 1 unresolved externals
Build failed.
For this I found this other reference:
- StackOverflow - unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
But that does not seen to fit. How to fix this `unresolved external symbol __dosmaperr`?
I found it inside the mysql5.0 folder. My sql version is `Mysql-Server 5.0.24a-win32`. Should I use another?
This is the one specified on the requirement script `mysqlver=mysql-noinstall-5.0.24a-win32`:
- https://github.com/alliedmodders/amxmodx/blob/master/support/checkout-deps.sh#L26-L28
The build steps are from:
https://wiki.alliedmods.net/Building_AMX_Mod_X
This is the mysql I am using:
https://github.com/evandrocoan/mysql-server
To build it I just to run `ambuild build` from the main folder, on the Mozilla Build Command Prompt window.
If I configure it to not use Mysql it successfully compiles:
PHP Code:
python ../configure.py --no-mysql
cd ..
ambuild build
...
Creating library amxmodx_mm.lib and object amxmodx_mm.exp
[38296] cp "amxmodx\amxmodx_mm\amxmodx_mm.dll" ".\packages\base\addons\amxmodx\dlls\amxmodx_mm.dll"
Build succeeded.
__________________