Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant compile. LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library #127

Open
m3fist0 opened this issue Feb 23, 2021 · 2 comments

Comments

@m3fist0
Copy link

m3fist0 commented Feb 23, 2021

im trying to compile luasql mysql via luarocks from windows but output looks like this, i download lasted mysql server version . what does he want?

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>luarocks install luasql-mysql
Installing https://luarocks.org/luasql-mysql-2.6.0-1.rockspec
Cloning into 'luasql'...
remote: Enumerating objects: 149, done.
remote: Counting objects: 100% (149/149), done.
remote: Compressing objects: 100% (99/99), done.
Receiving objects:  87% (130/149)sed 72 (delta 36), pack-reused 0R
Receiving objects: 100% (149/149), 104.13 KiB | 658.00 KiB/s, done.
Resolving deltas: 100% (72/72), done.
Note: switching to '22d4a911f35cf851af9db71124e3998d96fb3fa1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false


luasql-mysql 2.6.0-1 depends on lua >= 5.1 (5.3-1 provided by VM)
cl /nologo /MD /O2 -c -Fosrc/luasql.obj -IC:\luarocks/include src/luasql.c -Ic:/external/include
luasql.c
cl /nologo /MD /O2 -c -Fosrc/ls_mysql.obj -IC:\luarocks/include src/ls_mysql.c -Ic:/external/include
ls_mysql.c
link -dll -def:mysql.def -out:luasql/mysql.dll c:\luarocks/lib/lua53.lib src/luasql.obj src/ls_mysql.obj -libpath:c:/external mysqlclient.lib
Microsoft (R) Incremental Linker Version 14.25.28614.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library luasql\mysql.lib and object luasql\mysql.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp_RegCloseKey referenced in function "bool __cdecl win32_have_tcpip(void)" (?win32_have_tcpip@@YA_NXZ)
mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp_RegEnumValueA referenced in function "void __cdecl win_init_registry(void)" (?win_init_registry@@YAXXZ)
mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp_RegOpenKeyExA referenced in function "bool __cdecl win32_have_tcpip(void)" (?win32_have_tcpip@@YA_NXZ)
mysqlclient.lib(charset.obj) : error LNK2019: unresolved external symbol __imp___std_init_once_begin_initialize referenced in function "void __cdecl std::call_once<void (__cdecl&)(void)>(struct std::once_flag &,void (__cdecl&)(void))" (??$call_once@A6AXXZ$$V@std@@YAXAEAUonce_flag@0@A6AXXZ@Z)
mysqlclient.lib(charset.obj) : error LNK2019: unresolved external symbol __imp___std_init_once_complete referenced in function "void __cdecl std::call_once<void (__cdecl&)(void)>(struct std::once_flag &,void (__cdecl&)(void))" (??$call_once@A6AXXZ$$V@std@@YAXAEAUonce_flag@0@A6AXXZ@Z)
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp_EqualSid referenced in function "public: bool __cdecl Sid::operator==(class Sid const &)" (??8Sid@@QEAA_NAEBV0@@Z)
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp_GetTokenInformation referenced in function "public: __cdecl Sid::Sid(void *)" (??0Sid@@QEAA@PEAX@Z)
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp_IsValidSid referenced in function "public: bool __cdecl Sid::is_valid(void)const " (?is_valid@Sid@@QEBA_NXZ)
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp_LookupAccountNameW referenced in function "public: __cdecl Sid::Sid(wchar_t const *)" (??0Sid@@QEAA@PEB_W@Z)
luasql\mysql.dll : fatal error LNK1120: 9 unresolved externals

Error: Build error: Failed compiling module luasql/mysql.dll
@mavriq-dev
Copy link

On windows you need to link against Advapi32. So the rockspec needs a bit of a modification.

Use Luarocks unpack luasql-mysql

Then edit the luasql-mysql-2.6.0-1.rockspec file. Add advapi32 as shown below:

build = {
   type = "builtin",
   modules = {
     ["luasql.mysql"] = {
       sources = { "src/luasql.c", "src/ls_mysql.c" },
       libraries = { "mysqlclient", "Advapi32" },
       incdirs = { "$(MYSQL_INCDIR)" },
       libdirs = { "$(MYSQL_LIBDIR)" }
     }
   }

Then run

luarocks install luarocks luasql-mysql-2.6.0-1.rockspec

@20dka
Copy link

20dka commented Sep 5, 2024

Thanks @mavriq-dev , i got it to build with that. But actually running require("luasql.mysql") I get the error

error loading module 'luasql.mysql' from file 'C:\lua\luasql\mysql.dll':
        The specified module could not be found.

which I assume is related to a mysql library it can't find? I tried placing mysqlclient.lib next to it, and my lua.exe, neither helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants