News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DLL with polink: Unresolved external symbol

Started by jj2007, July 20, 2009, 10:17:01 AM

Previous topic - Next topic

jj2007

I am trying to produce a very simple dll. It works fine with link.exe but fails with polink:

Unresolved external symbol '_SayHello'

include \masm32\include\masm32rt.inc

.code
LibMain proc instance:DWORD, reason:DWORD, unused:DWORD
    mov eax, TRUE
    ret
LibMain endp

SayHello proc EXPORT MyText:DWORD
    invoke MessageBox, 0, MyText, chr$("I sit in a dll!"), MB_OK
    ret
SayHello endp

end LibMain


My def file is as follows:
LIBRARY "MiniDll"
EXPORTS
SayHello


Commandline:
\Masm32\bin\polink.exe /Subsystem:Windows /DLL /DEF:TmpDllEx.def  "MiniDll.obj" /OUT:MiniDll.dll

All that works perfectly with link.exe, versions 5.12 and 9.00

Any ideas?

dedndave

hiyas Jochen,
i am guessing the "_" decorator may have something to do with it
Erol is the guy to ask, of course - lol

Vortex

Hi Jochen,

No need to use a module definition file if you specify the EXPORT keyword below :

SayHello proc EXPORT MyText:DWORD

\masm32\bin\ml /c /coff MiniDLL.asm
\masm32\bin\polink /SUBSYSTEM:WINDOWS /DLL MiniDLL.obj


Linker : Polink Version 6.00.1

[attachment deleted by admin]

jj2007

#3
Hi Erol,

With your settings, it builds the dll but the exports are decorated:

this will work: mov pSayHello, rv(GetProcAddress, hDll, chr$("_SayHello@4"))
this does not work: mov pSayHello, rv(GetProcAddress, hDll, chr$("SayHello"))


The commandline /DLL /DEF:TmpDllEx.def will produce the "unresolved" error, if I uise only /dll, it links fine but again, I have the decorated names. How can I get rid of the decoration?

P.S.: The export.txt is apparently not needed, and has no influence on the result.

EDIT:

SayHello proc EXPORT MyText:DWORD

It works fine when I use the /def:Myfile.def option and take away the export keyword (the latter does not disturb link.exe...).

Edit(2): For RichMasm (see TheGuide, MiniDLL), I found a solution that works fine for link.exe and polink.exe:

QuoteSayHello proc MyText:DWORD  ; $export

The editor will create the .def file based on the names of those procedures that have $exp in the same line as the proc itself.