[How to Solve] Library not loaded: libmysqlclient.18.dylib

Exception code:

luasql = require("luasql.mysql");

Exception information:

lua: error loading module 'luasql.mysql' from file '/usr/local/lib/lua/5.3/luasql/mysql.so':
 dlopen(/usr/local/lib/lua/5.3/luasql/mysql.so, 6): Library not loaded: libmysqlclient.18.dylib
 Referenced from: /usr/local/lib/lua/5.3/luasql/mysql.so
 Reason: image not found
stack traceback:
 [C]: in ?
 [C]: in function 'require'
 /Users/daxuan/Documents/LuaWorkspace/22.Lua db.lua:5: in main chunk
 [C]: in ?
[Finished in 0.0s with exit code 1]
[cmd: ['lua', '/Users/daxuan/Documents/LuaWorkspace/22.Lua db.lua']]
[dir: /Users/daxuan/Documents/LuaWorkspace]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin]

Solution:

1. First find the location of libmysqlclient.18.dylib file in mysql, and then create a file link through ln command

2. The specific order is as follows

ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib

3. Done!

Similar Posts: