www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Windows 64-bit import library

reply Jordan Wilson <wilsonjord gmail.com> writes:
I'm trying to create an import library from a dll (in this case, 
a Lua dll).

Using dumpbin, I end up with a .def file:
EXPORTS
luaL_addlstring
luaL_addstring
luaL_addvalue
luaL_argerror
luaL_buffinit
...


I then use MS lib tool to generate a lib file:

lib /def:lua53.def /out:lua53.lib /machine:x64

I'm able to link the lib without errors (i.e. no "not valid lib" 
errors or anything), but that's as far as I get...any attempt to 
call functions results in:
undefined symbol: luaL_newstate
etc.

Is there any way I can generate the appropriate lib?

Else I think I'll need to get hold of the proper import libs that 
come with the Lua distribution.

Thanks,

Jordan
Jul 19 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Thursday, 19 July 2018 at 21:43:35 UTC, Jordan Wilson wrote:


 Is there any way I can generate the appropriate lib?

 Else I think I'll need to get hold of the proper import libs 
 that come with the Lua distribution.
Lua is extremely easy to build. That will generate the import lib for you.
Jul 19 2018
parent reply Jordan Wilson <wilsonjord gmail.com> writes:
On Friday, 20 July 2018 at 01:34:39 UTC, Mike Parker wrote:
 On Thursday, 19 July 2018 at 21:43:35 UTC, Jordan Wilson wrote:


 Is there any way I can generate the appropriate lib?

 Else I think I'll need to get hold of the proper import libs 
 that come with the Lua distribution.
Lua is extremely easy to build. That will generate the import lib for you.
I don't have MSVC, so I built it using mingw, which generated a .a lib. I shall google some more, as I understand it DMD -m64 uses Mingw libs as a fall back when MSVC not found, I compiled Lua using mingw, I can't be too much further away from being able to link in a 64-bit lua import lib in a 64-bit DMD compiled program...
Jul 19 2018
next sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Friday, 20 July 2018 at 04:31:38 UTC, Jordan Wilson wrote:

 I don't have MSVC, so I built it using mingw, which generated a 
 .a lib.
 I shall google some more, as I understand it DMD -m64 uses 
 Mingw libs as a fall back when MSVC not found, I compiled Lua 
 using mingw, I can't be too much further away from being able 
 to link in a 64-bit lua import lib in a 64-bit DMD compiled 
 program...
In that case, you may be better off using the DerelictLua binding [1] so that you can avoid the link-time dependency and just load the Lua DLL manually at runtime via `DerelictLua.load` [2]. Then it doesn't matter which compiler the DLL was compiled with or which toolchain you use to compile your app. Version 2.0.0-beta.2 (master and 2.0 branches) binds to Lua 5.3 (don't let the beta tag scare you -- it's stable). If you need Lua 5.2 instead, version 1.3.0 binds to it. [1] https://code.dlang.org/packages/derelict-lua [2] https://github.com/DerelictOrg/DerelictLua
Jul 19 2018
parent Jordan Wilson <wilsonjord gmail.com> writes:
On Friday, 20 July 2018 at 05:12:05 UTC, Mike Parker wrote:
 On Friday, 20 July 2018 at 04:31:38 UTC, Jordan Wilson wrote:

 I don't have MSVC, so I built it using mingw, which generated 
 a .a lib.
 I shall google some more, as I understand it DMD -m64 uses 
 Mingw libs as a fall back when MSVC not found, I compiled Lua 
 using mingw, I can't be too much further away from being able 
 to link in a 64-bit lua import lib in a 64-bit DMD compiled 
 program...
In that case, you may be better off using the DerelictLua binding [1] so that you can avoid the link-time dependency and just load the Lua DLL manually at runtime via `DerelictLua.load` [2]. Then it doesn't matter which compiler the DLL was compiled with or which toolchain you use to compile your app. Version 2.0.0-beta.2 (master and 2.0 branches) binds to Lua 5.3 (don't let the beta tag scare you -- it's stable). If you need Lua 5.2 instead, version 1.3.0 binds to it. [1] https://code.dlang.org/packages/derelict-lua [2] https://github.com/DerelictOrg/DerelictLua
Ah I think you have indirectly reminded me what the problem could be, the luaD wrapper that's available is for 5.1 I think (I'm trying to link lua 5.3). Your binding did work quite well, but I think I'll try again using lua 5.1, so I can keep using luaD. Thanks, Jordan
Jul 22 2018
prev sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Friday, 20 July 2018 at 04:31:38 UTC, Jordan Wilson wrote:
 On Friday, 20 July 2018 at 01:34:39 UTC, Mike Parker wrote:
 On Thursday, 19 July 2018 at 21:43:35 UTC, Jordan Wilson wrote:


 Is there any way I can generate the appropriate lib?

 Else I think I'll need to get hold of the proper import libs 
 that come with the Lua distribution.
Lua is extremely easy to build. That will generate the import lib for you.
I don't have MSVC, so I built it using mingw, which generated a .a lib. I shall google some more, as I understand it DMD -m64 uses Mingw libs as a fall back when MSVC not found, I compiled Lua using mingw, I can't be too much further away from being able to link in a 64-bit lua import lib in a 64-bit DMD compiled program...
what about passing your .def file directly with /DEF:your.def linker switch? more info https://msdn.microsoft.com/en-us/library/34c30xs1.aspx
Jul 20 2018
parent Jordan Wilson <wilsonjord gmail.com> writes:
On Friday, 20 July 2018 at 12:03:20 UTC, evilrat wrote:
 On Friday, 20 July 2018 at 04:31:38 UTC, Jordan Wilson wrote:
 On Friday, 20 July 2018 at 01:34:39 UTC, Mike Parker wrote:
 On Thursday, 19 July 2018 at 21:43:35 UTC, Jordan Wilson 
 wrote:


 Is there any way I can generate the appropriate lib?

 Else I think I'll need to get hold of the proper import libs 
 that come with the Lua distribution.
Lua is extremely easy to build. That will generate the import lib for you.
I don't have MSVC, so I built it using mingw, which generated a .a lib. I shall google some more, as I understand it DMD -m64 uses Mingw libs as a fall back when MSVC not found, I compiled Lua using mingw, I can't be too much further away from being able to link in a 64-bit lua import lib in a 64-bit DMD compiled program...
what about passing your .def file directly with /DEF:your.def linker switch? more info https://msdn.microsoft.com/en-us/library/34c30xs1.aspx
Thanks, I tried your suggestion, but received: lld-link: warning: <root>: undefined symbol: luaL_newstate lld-link: warning: <root>: undefined symbol: luaL_addlstring lld-link: warning: <root>: undefined symbol: luaL_addstring lld-link: warning: <root>: undefined symbol: luaL_addvalue lld-link: warning: <root>: undefined symbol: luaL_argerror lld-link: warning: <root>: undefined symbol: luaL_buffinit etc. I think I'll just have to obtain the lib from the LuaBinaries distribution. Thanks, Jordan
Jul 22 2018