Thread: Struggling with a new lua project

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,429

    Struggling with a new lua project

    I managed to resolve all my other errors but this set confounds me:
    Code:
    mingw32-make POE_BIT=64 -f makefile.mak
    ... Skipped messages about my variables ...
    gcc -ggdb -D _BUILD -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup -D WIN64 -mwindows -mwin32 -municode -ggdb  -o src/main.c-d.o -c src/main.c
    gcc -ggdb -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup -D WIN64 -mwindows -mwin32 -municode -o d-idlejp64.exe src/main.c-d.o src/mem.c-d.o
    src/main.c-d.o: In function `run':
    ... This part is what I can't understand why I'm getting them despite including the libraries ...
    O:\Data\C_Playground\idlejp/src/main.c:18: undefined reference to `luaL_newstate'
    O:\Data\C_Playground\idlejp/src/main.c:19: undefined reference to `luaL_openlibs'
    O:\Data\C_Playground\idlejp/src/main.c:20: undefined reference to `iuplua_open'
    O:\Data\C_Playground\idlejp/src/main.c:21: undefined reference to `luaL_loadfilex'
    O:\Data\C_Playground\idlejp/src/main.c:23: undefined reference to `lua_pcallk'
    O:\Data\C_Playground\idlejp/src/main.c:25: undefined reference to `lua_close'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make: *** [prj.mak:66: debug_PRJ] Error 1
    Compilation failed.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,811
    > -llua53 -liuplua53 -liup
    These need to be placed after the .o files compiled as part of your project.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,429
    Same result (unless I misunderstood):
    Code:
    mingw32-make POE_BIT=64 -f makefile.mak
    gcc -ggdb -D _BUILD -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -D WIN64 -mwindows -mwin32 -municode -ggdb  -o src/main.c-d.o -c src/main.c
    gcc -ggdb -D _BUILD -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -D WIN64 -mwindows -mwin32 -municode -ggdb  -o src/mem.c-d.o -c src/mem.c
    gcc -ggdb -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -D WIN64 -mwindows -mwin32 -municode -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup -o d-idlejp64.exe src/main.c-d.o src/mem.c-d.o
    src/main.c-d.o: In function `run':
    O:\Data\C_Playground\idlejp/src/main.c:18: undefined reference to `luaL_newstate'
    O:\Data\C_Playground\idlejp/src/main.c:19: undefined reference to `luaL_openlibs'
    O:\Data\C_Playground\idlejp/src/main.c:20: undefined reference to `iuplua_open'
    O:\Data\C_Playground\idlejp/src/main.c:21: undefined reference to `luaL_loadfilex'
    O:\Data\C_Playground\idlejp/src/main.c:23: undefined reference to `lua_pcallk'
    O:\Data\C_Playground\idlejp/src/main.c:25: undefined reference to `lua_close'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make: *** [prj.mak:66: debug_PRJ] Error 1
    Compilation failed.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,811
    Yes, you mis-understood.

    After your .o files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,429
    Thaaat's better, still came out with a wierd error however:
    Code:
    mingw32-make POE_BIT=64 -f makefile.mak (in directory: O:\Data\C_Playground\idlejp)
    gcc -ggdb -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -D WIN64 -mwindows -mwin32 -municode -o src/main.c-d.o -c src/main.c -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup
    gcc -ggdb -Wall -I "../lua64-53/include" -I "../iup64-3.25/include" -D WIN64 -mwindows -mwin32 -municode -o src/mem.c-d.o -c src/mem.c -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup
    gcc -ggdb  -o d-idlejp64.exe src/main.c-d.o src/mem.c-d.o -L "../lua64-53" -L "../iup64-3.25/Lua53" -L "../iup64-3.25"  -llua53 -liuplua53 -liup
    x:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/6.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make: *** [prj.mak:77: debug_PRJ] Error 1
    Compilation failed.
    Despite me having this in main.c:
    Code:
    # if defined( _UNICODE ) || defined( UNICODE )
    #		define POE_UNICODE
    #	endif
    #	ifdef POE_UNICODE
    int CALLBACK wWinMain(
    	HINSTANCE hThis,
    	HINSTANCE hPrev,
    	LPWSTR lpCmdLine,
    	int iCmdShow )
    #	else
    int CALLBACK WinMain(
    	HINSTANCE hThis,
    	HINSTANCE hPrev,
    	LPSTR lpCmdLine,
    	int iCmdShow )
    #	endif
    Any ideas as to why it is expecting the wrong function?

  6. #6
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,429
    Didn't manage to fix root cause but the app compiled fine once I used both wWinMain & WinMain, my next problem lies with running my lua file, loads fine but doesn't run, just in case can you see anything wrong at all?
    Code:
    lua_State *L = luaL_newstate();
      luaL_openlibs(L);
      iuplua_open(L);
      if(luaL_loadfile(L,"main.lua"))
    		bail(L,"Failed to load main.lua");
      if(lua_pcall( L, 0, 0, 0 ))
    		bail(L,"Failed to run main.lua");
      lua_close(L);
    While you're looking I'll investigate a different suspicion I have related to an apparent MS oversight in CommandLineToArgvW, I made a function to wrapup the exe part and add "0 " before it before calling the function but haven't got round to filtering that "0 " back out after calling it.

    Edit: Nope had nothing to do with it
    Edit 2: Finally got my compiler to stop complaining of missing lua_tostring so I could diagnose the error and found I had forggoten to actually create a lua file that main.lua was expecting, so went and did that with a basic parameter to build my GUI with (IUP is helpful in that regard) and lua started complaing of invalid characters or something to that effect, here's what my other file consists of for now:
    Code:
    local list = {
    	"時々" = {}
    }
    Any ideas of how to handle UTF16 characters?
    Last edited by awsdert; 11-30-2018 at 10:41 AM.

  7. #7
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,429
    Post is getting a bit big so here's new one, I managed to get lua to except the name, I've used UTF8 encoding with my file looking like this for now:
    Code:
    local list = {}
    list["時々"] = {}
    Got a different error now related to IUP so I will have to go it alone for now or contact the developer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Struggling with VEX programing
    By sixtysix in forum C Programming
    Replies: 1
    Last Post: 05-16-2016, 04:16 AM
  2. Struggling With the Next Step.
    By Dobblaar in forum C Programming
    Replies: 8
    Last Post: 11-28-2013, 05:06 PM
  3. Need some help with this code. Struggling
    By NoobCoder85 in forum C++ Programming
    Replies: 2
    Last Post: 11-25-2013, 02:34 AM
  4. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  5. Struggling in programming pic18f452
    By m.zintan in forum C++ Programming
    Replies: 6
    Last Post: 11-24-2010, 09:41 AM

Tags for this Thread