[Solved] REASM a DLL not working

Just starting out? Need help? Post your questions and find answers here.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

[Solved] REASM a DLL not working

Post by chi »

It was already addressed here, but not as a bug... So here is the official bug report ;)

Code: Select all

D:\Program Files\PureBasic5.60(x86)\Compilers>pbcompiler.exe /REASM /DLL PureBasic.asm

******************************************
PureBasic 5.60 (Windows - x86)
******************************************

Compiling PureBasic.asm
Loading external libraries...
ReAssembling source code...
Creating DLL "PureBasic.dll"
Error: Linker
POLINK: fatal error: Unable to read module-definition file 'PureBasic.def'.
Last edited by chi on Sun Apr 23, 2017 2:40 pm, edited 1 time in total.
Et cetera is my worst enemy
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: REASM a DLL not working

Post by chi »

OK, I figured it out... Let me know if you're even interested, because it's a little bit cumbersome and creating a walkthrough would take some time.

In addition I also learned how to link with polink v8 8)
Et cetera is my worst enemy
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: REASM a DLL not working

Post by skywalk »

Whoa, that is great. I tried a while back and failed with different settings and gave up.
I was attempting to automate dead code removal with the flattened asm, but the output format changed. I cannot find my stale procedure calls to delete prior to reasm.
But, it would be good to know how to automate builds with reasm and any compiler setting?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: REASM a DLL not working

Post by chi »

...it's a little bit cumbersome and creating a walkthrough would take some time
Turns out everything works so much better when A) operating from the PB compiler directory and B) not having a different version of polink installed ;).

In a nutshell:

Put your .pb file into #PB_Compiler_Home + "Compilers\" and open a command prompt:

1) First you need the PureBasic.asm and PureBasic.def file:

Code: Select all

pbcompiler.exe /COMMENTED /DLL "my_dll.pb"
2) You can REASM now:

Code: Select all

pbcompiler.exe /REASM /DLL "PureBasic.asm"
3) If you want to follow the calling convention and decorate your library accordingly (e.g. x86 stdcall), you need to edit PureBasic.def: (Optional)

Code: Select all

LIBRARY "PureBasic.dll"
EXPORTS
"MsgBox"="Procedure8"
...
to

Code: Select all

LIBRARY "PureBasic.dll"
EXPORTS
"_MsgBox@8"="Procedure8"
...
4) Update PureBasic.lib to include your exports:

Code: Select all

polib.exe /VERBOSE /DEF:"PureBasic.def" /OUT:"PureBasic.lib"
That's all folks :D
cheers, chi
Et cetera is my worst enemy
Post Reply