Page 1 of 1
how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 6:23 pm
by skinkairewalker
hi everyone !
somenone can help me ?
how can i convert .dll in .lib and .lib in .dll ?
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 8:53 pm
by jack
hello
I know how to convert a mingw lib to a dll but have not done so using VS or PellesC which is probably what you want, as for converting a dll to a lib I don't know how one would go about it, there use to be a commercial software that claimed to do so but the price was like $999.
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 9:25 pm
by Lunasole
There are 2 kinds of .lib (statical library on windows):
- first contains all the functions and their code, program used this lib is fully independent.
- second contains only function descriptions from some .dll file. code is located in dll and program uses this lib cannot start without required dll.
If you have .dll and don't have it's source code, you can only build second kind of .lib. That can be done using POLIB.EXE (comes with Purebasic), or more handy "Lib2PB Import" tool (search in google or here on forum).
If you have full sources (usually C or C++), you can compile both types of lib and dll from it, which sometime requires code changes (generally for dlls you need to mark export table) and will be painful for first times.
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 10:12 pm
by jack
if you have a static lib (not an import lib) you should be able to extract the objects and then use link to create a dll, something like link /DLL /IMPLIB:mylib.lib /OUT:mylib.dll *.obj
I just tried to extract the objects from a static lib using ar and it worked ok, (ar x yourlib.lib)
[edit] just remembered that polib has an explode option to extract objects from static lib
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 10:40 pm
by sys64802
jack wrote:there use to be a commercial software that claimed to do so but the price was like $999.
This can be tried, says it's fully working but time limited until registered. 32 bit only.
http://www.binary-soft.com/dll2lib/dll2lib.htm
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Mon Aug 15, 2016 10:46 pm
by jack
I see he lowered the price, $100 is not so bad, but with 32-bit only it's usefulness is limited.
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Tue Aug 16, 2016 1:58 am
by Keya
another option instead of dll-to-lib (i think currently PB code only exists for Windows though):
if you just want the effect of having the .dll inside your exe (no separate dll file on disk, good if you just want a single executable to distribute without dependencies!) you could use one of those slick "load dll from memory" functions

[
Example]
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Tue Aug 16, 2016 7:26 pm
by sys64802
@keya
uhm, that one looks a little too simple and doesn't support some things... I don't think it can really work, or maybe can work only in some cases. Did you try it and worked ?
The one in C from the library is certainly a lot better even if probably still not perfect. But it's good enough.
http://www.purebasic.fr/english/viewtop ... 99#p323299
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Tue Aug 16, 2016 7:39 pm
by Keya
yes it works well. I havent tried the one you linked to but i noticed it comes with just the one .lib file, wouldnt it need two to support both x86 and x64? im not sure
Re: how can i convert .dll in .lib and .lib in .dll ?
Posted: Tue Aug 16, 2016 9:48 pm
by sys64802
That was a older link sorry, at the time I downloaded it from here
http://www.realsource.de/downloads/doc_ ... morymodule
That was the one I was using before writing my own, and it worked well with the dll I tried (just two or three).
That's why I know that one is nice, because I studied its source well (it's very educational) before writing my version which has some differences.
The one you linked in source doesn't work as it is anymore, removing the structures already defined in PB now and removing the unpackmemory() to make it compile (not executed anyway with an unpacked dll) it crashes with the dll I'm testing it with at
Code: Select all
If CallFunctionFast(BaseVirtDll + *NT_HEADERS\OptionalHeader\AddressOfEntryPoint, BaseVirtDll, #DLL_PROCESS_ATTACH, 0)
Same dll with the library above it's working, but I don't have the desire to try to understand why it doesn't with this source
Maybe you modified it, or maybe the structures are different ? Don't know. Anyway just looking at it it seems to me also it doesn't support
function forwarding, and that can be found in many dlls, especially OS dlls.
Anyway the lib above it's both 32 and 64 bits if you are interested.