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

Cannot compile with luarocks under Windows #44

Open
oktoberfest6 opened this issue Sep 14, 2022 · 0 comments
Open

Cannot compile with luarocks under Windows #44

oktoberfest6 opened this issue Sep 14, 2022 · 0 comments

Comments

@oktoberfest6
Copy link

Hi,

I'm trying to install Lrexlib-PCRE with luarocks under Windows (with the help of vcpkg).

When running 'luarocks install Lrexlib-PCRE' I get the following message:

src/pcre/lpcre.c(451): error C2491: 'luaopen_rex_pcre': definition of dllimport function not allowed

The line 451 is:

REX_API int REX_OPENLIB (lua_State *L) {

REX_API is defined as a synonym for LUALIB_API (common.h)

#ifndef REX_API
#  define REX_API LUALIB_API
#endif

LUALIB_API is a synonym for LUA_API (luaconf.h):

#define LUALIB_API	LUA_API

The problem is that (under Windows) LUA_API is a conditional define (luaconf.h):

#if defined(LUA_CORE) || defined(LUA_LIB)       /* { */
#define LUA_API __declspec(dllexport)
#else                                           /* }{ */
#define LUA_API __declspec(dllimport)
#endif                                          /* } */

Lua compiled modules should define LUA_LIB before including any lua header file so that LUA_API is correctly defined (__declspec(dllexport) will export the entry point)

With a very small change in the rockspec I managed to compile
before:

      defines = {
        "VERSION=\"2.9.1\"",
        "PCRE2_CODE_UNIT_WIDTH=8",
      },

after:

      defines = {
	"LUA_LIB=",
        "VERSION=\"2.9.1\"",
        "PCRE2_CODE_UNIT_WIDTH=8",
      },

Can you update the rockspec ?

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

No branches or pull requests

1 participant