lua-rapidjson icon indicating copy to clipboard operation
lua-rapidjson copied to clipboard

windows mingw64, can not link to lua51.dll

Open CanYellow opened this issue 2 years ago • 1 comments

platform

windows10, mingw64 with cmake

problem

  • building when using 'luarocks --tree luamodules install rapidjson', the ld.exe will throw a link error:
D:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find D:ProgramFileslua51bin/lua51.dll: No such file or directory
  • config use default lua libdir setting. the config file is as follow:
variables = {
    MSVCRT = 'm',   -- make MinGW use MSVCRT.DLL as runtime
    LUALIB = 'lua51.dll',
    CC = [[D:\ProgramFiles\msys64\mingw64\bin\gcc.exe]],
    MAKE = [[D:\ProgramFiles\msys64\mingw64\bin\gnatmake.exe]],
    RC = [[D:\ProgramFiles\msys64\mingw64\bin\windres.exe]],
    LD = [[D:\ProgramFiles\msys64\mingw64\bin\gcc.exe]],
    AR = [[D:\ProgramFiles\msys64\mingw64\bin\ar.exe]],
    RANLIB = [[D:\ProgramFiles\msys64\mingw64\bin\ranlib.exe]],
}

solution

manual set the LUA_LIBDIR value. the config file is as follow:

variables = {
    MSVCRT = 'm',   -- make MinGW use MSVCRT.DLL as runtime
    LUALIB = 'lua51.dll',
    -- for cmake the default libdir string is 'D:/ProgramFiles/lua51/bin' which when attaching to ld.exe, it will parse as D:ProgramFileslua51bin. so manual config libdir as 'D:/ProgramFiles/lua51/bin'
    LUA_LIBDIR = 'D:/ProgramFiles/lua51/bin',
    CC = [[D:\ProgramFiles\msys64\mingw64\bin\gcc.exe]],
    MAKE = [[D:\ProgramFiles\msys64\mingw64\bin\gnatmake.exe]],
    RC = [[D:\ProgramFiles\msys64\mingw64\bin\windres.exe]],
    LD = [[D:\ProgramFiles\msys64\mingw64\bin\gcc.exe]],
    AR = [[D:\ProgramFiles\msys64\mingw64\bin\ar.exe]],
    RANLIB = [[D:\ProgramFiles\msys64\mingw64\bin\ranlib.exe]],
}

question

is there any improvement about the above problem in the furture rapidjson rocks update version?

CanYellow avatar Jun 25 '23 00:06 CanYellow

I'm newer to this repository, so please heed my late comment.

The issue comes from ld.exe: cannot find D:ProgramFileslua51bin/lua51.dll, where the \\ char is being subbed out for "" instead of / on Windows. You can fix this temporarily by adding the flag like:

luarocks install rapidjson LUA_LIBDIR="D:\Program Files\lua51\bin\"

I am making a pull request to fix this in the cmake file. Also, the space char in Program Files may be also causing path issues.

saspivey98 avatar Aug 25 '25 19:08 saspivey98