Closed alex1543 closed 7 months ago
Looks like the mysql client library is not linked. On Windows, it is called libmysql.lib
, on Linux it is called libmysqlclient.a
. I'm not sure if rdmd links it in automatically but it should be... make sure the file is there and maybe try adding it to your build command and see what happens.
also possible they've changed it over the years, like it might need to be extern(C) instead of extern(System) nowadays. I haven't tested it on Windows for a very long time.
When can we expect a fixed MySQL module for the D language?
Maybe some time after you check for your own other mistakes. Did you link in the library? Which one? How did you install it?
The version of the libmysql.dll library is taken from mysql-8.0.32-winx64. Then I copied all the files from the C:\mysql-8.0.32-winx64\lib directory to C:\Dlang\dmd2\src\phobos\arsd\ . The file not found error is gone. But now there are many other errors when rdmd mysql.d command:
C:\xampp\htdocs\practD\arsd>rdmd mysql.d
lld-link: error: undefined symbol: _mysql_free_result@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult6__dtorMFNlZv)
lld-link: error: undefined symbol: _mysql_num_fields@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult6fieldsMFZASQBkQBi11MYSQL_FIELD)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult16makeFieldMappingMFZv)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult9fetchNextMFZv)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult10fieldNamesMFZAAya)
lld-link: error: undefined symbol: _mysql_fetch_fields@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult6fieldsMFZASQBkQBi11MYSQL_FIELD)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult16makeFieldMappingMFZv)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult10fieldNamesMFZAAya)
lld-link: error: undefined symbol: _mysql_num_rows@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult6lengthMFZk)
lld-link: error: undefined symbol: _mysql_fetch_row@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult9fetchNextMFZv)
lld-link: error: undefined symbol: _mysql_fetch_lengths@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql11MySqlResult9fetchNextMFZv)
lld-link: error: undefined symbol: _mysql_init@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql6__ctorMFAyaQdQfQhkZCQBmQBkQBh)
lld-link: error: undefined symbol: _mysql_real_connect@32
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql6__ctorMFAyaQdQfQhkZCQBmQBkQBh)
lld-link: error: undefined symbol: _mysql_error@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql5errorMFZAya)
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql7prepareFNeCQxQu5MySqlAyaZPSQBnQBl9Statement)
lld-link: error: undefined symbol: _mysql_close@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql5closeMFZv)
lld-link: error: undefined symbol: _mysql_insert_id@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql12lastInsertIdMFZi)
lld-link: error: undefined symbol: _mysql_real_escape_string@16
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql6escapeMFAyaZQe)
lld-link: error: undefined symbol: _mysql_affected_rows@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql12affectedRowsMFZi)
lld-link: error: undefined symbol: _mysql_query@8
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql9queryImplMFAyaAS3std7variant__T8VariantNVki20ZQpXCQCq8database9ResultSet)
lld-link: error: undefined symbol: _mysql_store_result@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql5MySql9queryImplMFAyaAS3std7variant__T8VariantNVki20ZQpXCQCq8database9ResultSet)
lld-link: error: undefined symbol: _mysql_stmt_close@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql9Statement6__dtorMFZv)
lld-link: error: undefined symbol: _mysql_stmt_reset@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql9Statement5resetMFZv)
lld-link: error: undefined symbol: _mysql_stmt_init@4
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql7prepareFNeCQxQu5MySqlAyaZPSQBnQBl9Statement)
lld-link: error: undefined symbol: _mysql_stmt_prepare@12
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql7prepareFNeCQxQu5MySqlAyaZPSQBnQBl9Statement)
lld-link: error: undefined symbol: _mysql_stmt_bind_param@8
>>> referenced by C:\Users\alex\AppData\Local\Temp\.rdmd\rdmd-mysql.d-9DFE1FB0A15A4676395EE877547F4B5F\objs\mysql.exe.obj:(__D4arsd5mysql17bindParameterNullFPSQBhQBf9StatementZv)
lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
Error: linker exited with status 1
Linking errors, I understand? The same thing was done with Ruby , no errors occurred. Perhaps a specific version of libmysql.dll is required that is guaranteed to work with Dlang or mysql.d?
Edit your copy of the mysql.d file and change the extern(System)
to extern(C)
and then recompile, let me know if that changes anythign.
Replacing extern(System) to extern(C) didn't work for mysql-8.0.32-winx64. But it works with mysql-5.0.15-win32 . Only works via rdmd app.d , compiling via dub build does not work.
Perhaps the "dub build" command requires a specific version of mysql to compile and not mysql-5.0.15-win32 ?
C:\xampp\htdocs\practD\mdb1\source>rdmd app.d
Unloading from MySQL works.
[SELECT * FROM myarttable]
17 17 Baranov Engeneer
92 92 Daniel Artist
93 93 Andrew Poet
94 94 Nikita Student
96 96 Matvey Programmer
98 98 Ivan Student
99 99 Alexey Engineer
C:\xampp\htdocs\practD\mdb1\source>cd ..
C:\xampp\htdocs\practD\mdb1>dub build
Starting Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
Up-to-date mysql-d 0.3.3: target for configuration [mysql-d] is up to date.
Building mdb1 ~master: building configuration [application]
Linking mdb1
lld-link: error: undefined symbol: _D4arsd5mysql5MySql6__ctorMFAyaQdQfQhkZCQBmQBkQBh
>>> referenced by C:\xampp\htdocs\practD\mdb1\source\app.d:9
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd8database3Row7opIndexMFAyaQdiZQh
>>> referenced by C:\xampp\htdocs\practD\mdb1\source\app.d:12
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd8database3Row7opIndexMFmAyaiZQf
>>> referenced by C:\xampp\htdocs\practD\mdb1\source\app.d:12
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_Dmain)
>>> referenced by C:\xampp\htdocs\practD\mdb1\source\app.d:12
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_Dmain)
>>> referenced by C:\xampp\htdocs\practD\mdb1\source\app.d:12
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd5mysql5MySql6__initZ
>>> referenced by C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d:2734
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_D4core8lifetime__T12_d_newclassTTC4arsd5mysql5MySqlZQBiFNaNbNeZQBe)
lld-link: error: undefined symbol: _D4arsd5mysql5MySql7__ClassZ
>>> referenced by C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d:2755
>>> C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_D4core8lifetime__T12_d_newclassTTC4arsd5mysql5MySqlZQBiFNaNbNeZQBe)
lld-link: error: undefined symbol: _D4arsd5mysql12__ModuleInfoZ
>>> referenced by C:\Users\alex\AppData\Local\dub\cache\mdb1\~master\build\application-debug-K1yWhXbYa0OYkKuM624dJw\mdb1.obj:(_D3app12__ModuleInfoZ)
Error: linker exited with status 1
Error C:\D\dmd2\windows\bin64\dmd.exe failed with exit code 1.
Compiling dmd app.d fails with the same options rdmd app.d and mysql-5.0.15-win32 , but rdmd app.d works.
C:\xampp\htdocs\practD\mdb1\source>rdmd app.d
Unloading from MySQL works.
[SELECT * FROM myarttable]
17 17 Baranov Engeneer
92 92 Daniel Artist
93 93 Andrew Poet
94 94 Nikita Student
96 96 Matvey Programmer
98 98 Ivan Student
99 99 Alexey Engineer
C:\xampp\htdocs\practD\mdb1\source>dmd app.d
lld-link: error: undefined symbol: _D4arsd5mysql5MySql6__ctorMFAyaQdQfQhkZCQBmQBkQBh
>>> referenced by app.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd8database3Row7opIndexMFAyaQdiZQh
>>> referenced by app.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd8database3Row7opIndexMFmAyaiZQf
>>> referenced by app.obj:(_Dmain)
>>> referenced by app.obj:(_Dmain)
>>> referenced by app.obj:(_Dmain)
lld-link: error: undefined symbol: _D4arsd5mysql5MySql6__initZ
>>> referenced by app.obj:(_D4core8lifetime__T12_d_newclassTTC4arsd5mysql5MySqlZQBiFNaNbNeZQBe)
lld-link: error: undefined symbol: _D4arsd5mysql5MySql7__ClassZ
>>> referenced by app.obj:(_D4core8lifetime__T12_d_newclassTTC4arsd5mysql5MySqlZQBiFNaNbNeZQBe)
lld-link: error: undefined symbol: _D4arsd5mysql12__ModuleInfoZ
>>> referenced by app.obj:(_D3app12__ModuleInfoZ)
Error: linker exited with status 1
That's normal, plain dmd doesn't include library modules. You should dmd -i
to include them and then it'd work the same as rdmd.
But it looks like they changed the linkage model between 5 and 8. Mysql has always been kinda annoying about that, I'll get an updated 64 bit thing installed and see what I can do.
I just installed the newest mysql version 8 and everything worked fine without modification.
I just had to give the path to mysqlclient.lib to the build.
dmd -i testmysql "c:\program files\mysql\mysql server 8.0\lib\libmysql.lib"
and then bring the libmysql.dll out with my exe and it ran. I did have to do a 64 bit build since i installed the 64 bit mysql but it worked.
Isn't it difficult for you to make a 64 bit compilation distribution so that it is available to everyone?
You just build with -m64 or whatever, this is available to everyone.
Dear Developer,
The arsd.mysql module does not work. What could be the problem?
Sample code for working with arsd.mysql:
Sincerely, Alexey