Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

I need advice on setup compiler for c library with embedded lua in Cygwin with Mingw on Windows

$
0
0

I am learning how to create a c library with embedded Lua. Sounds simple with everyone but I stuck at compiling the code. Please points me to what I did wrong in follow steps. The important key is I need to use MinGW-w64 toolchain, this is the reason I use Cygwin.

  1. First I install lua and liblua-dev in Cygwin. I chose version 5.3.6-4.From Cygwin, I can run lua file.lua which print a string on the Cygwin terminal.

    print('Hi from script.lua!')

  2. Then I install MinGW-w64 toolchain and add "C:\msys64\ucrt64\bin" to the user environment variables.From Cygwin, I can test the gcc version work correctly.

    $ cc --versioncc.exe (Rev3, Built by MSYS2 project) 13.2.0

    Copyright (C) 2023 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I create a doscript.c file as below

#include "lauxlib.h"#include "lua.h"#include "lualib.h"int main(){    lua_State *L = luaL_newstate();    luaL_openlibs(L);    luaL_dofile(L, "script.lua");    lua_close(L);    return 0;}

When I ran command to compile, I got below error

$ cc doscript.c -o doscript -lluaC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llua: No such file or directorycollect2.exe: error: ld returned 1 exit status

From Cygwin if I list the usr/lib, I can see the liblua5.3.dll.a

$ ls /usr/libcharset.alias  engines-3  liblua-5.3.dll.a  ossl-modules      pkgconfigcsih           gawk       liblua.dll.a      p11-kit-proxy.so  sasl2_3engines-1.0    groff      liblua5.3.dll.a   perl5             securityengines-1.1    libcbor.a  lua               pkcs11            terminfo

I also tried with the actual library name but still get error

$ cc doscript.c -o doscript -L/usr/lib -llua-5.3.dllC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llua-5.3.dll: No such file or directorycollect2.exe: error: ld returned 1 exit status

Is there anything else I should try?Thank you in advance!


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>