News:

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

GetProcAddress 'Gotcha'

Started by zooba, January 02, 2006, 06:24:07 AM

Previous topic - Next topic

zooba

I just discovered a rather annoying linker option which I hadn't come across before and I thought was worth sharing.

If you are using LINK.EXE (the Microsoft linker, I have version 7.10) with the /DEBUG option and you have LoadLibrary/GetProcAddress calls in your program, the assembler (or linker - I'm not 100% sure) will recognise and statically link them instead. This was very upsetting when I was compiling a debug version on WinXP then moving it to my Win2K box and being told that HeapSetInformation wasn't available - even though it's dynamically linked.

The simple solution is to also use the /OPT:REF option as well. This eliminates unreferenced functions and solves the issue. It also produces much smaller executables compared to a debug version without the option (/DEBUG implies /OPT:NOREF).

Hope this helps somebody out there  :wink :U

Cheers,

Zooba

ThoughtCriminal

If you using VC as you IDE a lot of libs are included automaically as well.  Look at the command line.  No optin to turn it off as far as I know.

P1

zooba,

Please post the whole line from your build/make file.

I wanted to compare it to mine:
\masm32\bin\Link /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"%1" "%1.obj" rsrc.obj

Regards,  P1  :8)

zooba

Exactly the same, except I leave out the deprecated /DEBUGTYPE flag and let it choose the PDB name by itself:

\masm32\bin\Link /DEBUG /OPT:REF /SUBSYSTEM:WINDOWS %1.obj

My build tool generates the command based on simpler options, so it's not identical to that one, but that's the gist of it. :U

Cheers,
Zooba

P1

Thanks, I'll try this out.

Regards,  P1  :8)