View previous topic :: View next topic |
Author |
Message |
Scorm Newbie cheater Reputation: 0
Joined: 06 Dec 2018 Posts: 11
|
Posted: Mon Dec 17, 2018 4:17 pm Post subject: Unable to load compiled C lib in LUA (64-bit DLL) |
|
|
Hello,
I tried to "require" a compiled C lib in LUA from CE 6.8.1 64-bit.
The lib was compiled with GCC, using the LUA header from CE's install dir. I also used "lua53-64.dll".
The DLL was placed in CE's root dir. On LUA script execution :
Code: | Error:error loading module 'winapi' from file 'C:\Program Files (x86)\Cheat Engine 6.8.1\winapi.dll':
%1 is not a valid Win32 application. |
At the moment, I am unable to compile a 32-bit DLL. It is required to do so ?
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Mon Dec 17, 2018 6:07 pm Post subject: |
|
|
If you are using 64bit CE, you need to use a 64bit DLL.
If you want to load a 32bit DLL, then use 32bit CE.
_________________
- Retired. |
|
Back to top |
|
|
Scorm Newbie cheater Reputation: 0
Joined: 06 Dec 2018 Posts: 11
|
Posted: Mon Dec 17, 2018 7:17 pm Post subject: |
|
|
I used CE 64-bit... so I am very confused... like you probably.
EDIT : Downloaded 32-bit compiler to try and compile 32-bit DLL to see if it would work and ended up showing the same error message.
Tried to recompile again in 64-bit, compilation error from GCC :
Code: | ...\winapi>REM compiling for mingw against msvcrt
...\winapi>set LUA_DIR=...\winapi
...\winapi>set CFLAGS=-c -g -DPSAPI_VERSION=1 -I"...\winapi"
...\winapi>gcc -c -g -DPSAPI_VERSION=1 -I"...\winapi" winapi.c
...\winapi>gcc -c -g -DPSAPI_VERSION=1 -I"...\winapi" wutils.c
...\winapi>gcc -g -shared winapi.o wutils.o "...\winapi\lua53-64.dll" -lpsapi -lMpr -o winapi.dll
...lua53-64.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
|
Last edited by Scorm on Tue Dec 18, 2018 8:14 am; edited 1 time in total |
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Mon Dec 17, 2018 10:33 pm Post subject: |
|
|
You are still mixing bit modes which you can't.
If you are using 32bit CE, you have to use 32bit DLLs.
If you are using 64bit CE, you have to use 64bit DLLs.
You need to compile things for the proper bit mode you plan to use.
_________________
- Retired. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Tue Dec 18, 2018 12:55 am Post subject: |
|
|
you need to build with the .lib , not the dll
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Scorm Newbie cheater Reputation: 0
Joined: 06 Dec 2018 Posts: 11
|
Posted: Tue Dec 18, 2018 8:13 am Post subject: |
|
|
Dark Byte wrote: | you need to build with the .lib , not the dll |
I checked my Win7 "PATH" and the path to the x86 compiler was inserted before the x64 so I removed it...
Tried with lua53-64.lib and here is the compilation output :
Code: |
...\winapi>REM compiling for mingw against msvcrt
...\winapi># set LUA_DIR=D:\dev\lua\luajit-2.0\src
...\winapi>set LUA_INCLUDE=C:\Program Files (x86)\Cheat Engine 6.8.1\plugins
...\winapi>set LUA_LIB=C:\Program Files (x86)\Cheat Engine 6.8.1\plugins\lua53-64.lib
...\winapi>set CFLAGS=-c -m64 -O1 -DPSAPI_VERSION=1 -I"C:\Program Files (x86)\Cheat Engine 6.8.1\plugins"
...\winapi>gcc -c -m64 -O1 -DPSAPI_VERSION=1 -I"C:\Program Files (x86)\Cheat Engine 6.8.1\plugins" winapi.c
...\winapi>gcc -c -m64 -O1 -DPSAPI_VERSION=1 -I"C:\Program Files (x86)\Cheat Engine 6.8.1\plugins" wutils.c
...\winapi>gcc -Wl,-s -shared winapi.o wutils.o "C:\Program Files (x86)\Cheat Engine 6.8.1\plugins\lua53-64.lib" -lpsapi -lMpr -o winapi.dll
|
Errors :
Code: | '#' is not recognized as an internal or external command,
operable program or batch file.
winapi.l.c: In function 'l_window_from_handle':
winapi.l.c:405:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
return push_new_Window(L, (HWND)hwnd);
^
winapi.o:winapi.c:(.text+0x13): undefined reference to `lua_newuserdata'
winapi.o:winapi.c:(.text+0x2a): undefined reference to `lua_getfield'
winapi.o:winapi.c:(.text+0x37): undefined reference to `lua_setmetatable'
winapi.o:winapi.c:(.text+0x5e): undefined reference to `lua_newuserdata'
winapi.o:winapi.c:(.text+0x75): undefined reference to `lua_getfield'
winapi.o:winapi.c:(.text+0x82): undefined reference to `lua_setmetatable'
winapi.o:winapi.c:(.text+0xc8): undefined reference to `luaL_checklstring'
... (375 undefined references total, non unique)
wutils.o:wutils.c:(.text+0x589): undefined reference to `lua_pushlstring'
collect2.exe: error: ld returned 1 exit status
|
I am able to find those symbols in lua53-64.lib, so I believe this is a linking issue.
Extra :
The undefined references go away when I remove the "-s" symbols flag, but the compilation still doesn't go through.
I tried using the compiler flags "-static", "-static-libgcc" and "-static-libstdc++" in the last gcc command of the compiling bat script.
Code: |
set LUA_INCLUDE=C:\Program Files (x86)\Cheat Engine 6.8.1\plugins
set LUA_LIB=C:\Program Files (x86)\Cheat Engine 6.8.1\plugins\lua53-64.lib
set CFLAGS=-c -m64 -O1 -DPSAPI_VERSION=1 -I"%LUA_INCLUDE%"
gcc %CFLAGS% winapi.c
gcc %CFLAGS% wutils.c
gcc -Wl, -static-libgcc winapi.o wutils.o "%LUA_LIB%" -lpsapi -lMpr -o winapi.dll |
I don't get undefined references, but this errror :
Code: | winapi.l.c: In function 'l_window_from_handle':
winapi.l.c:405:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
return push_new_Window(L, (HWND)hwnd);
^
C:/Qt/Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find : Invalid argument
collect2.exe: error: ld returned 1 exit status |
|
|
Back to top |
|
|
noobes Advanced Cheater Reputation: 0
Joined: 17 Dec 2018 Posts: 89
|
Posted: Fri Dec 28, 2018 4:40 am Post subject: |
|
|
use .lib
|
|
Back to top |
|
|
|