Tip when building LIB files with GoAsm and MS Lib.exe

Started by donkey, April 05, 2011, 09:44:48 PM

Previous topic - Next topic

donkey

I have been building a couple of LIB projects over the last few weeks and have a tip to pass along. If your LIB is meant to be used by MASM as well as GoAsm, it is important not to use the directive #dynamiclinkfile anywhere in the source since when you try to build a MASM project using the LIB you'll get a LNK1276 error "invalid directive 'directive' found; does not start with '/'". This appears to be because GoAsm uses the directive section of the PE to store the DLL's to be searched at link time, however ML.EXE also uses that section to pass instructions to the linker and the two are incompatible. Since MASM's link.exe does not recognize these directives it will throw that error. The DLL imports are not necessary when building a LIB and should always be left out, that includes not defining the LINKFILES switch for the header project.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

not sure i understand, Edgar

if i build a static library that requires, say...
        INCLUDE    \masm32\include\advapi32.inc
        INCLUDELIB \masm32\lib\advapi32.lib


are you saying i should leave out the INCLUDELIB ???

donkey

Hi Dave,

In MASM as in GoAsm calling the lib will work as usual, this tip was for the building of the static library itself using GoAsm. The reason for this is how GoAsm (and MASM) pass directives to the linker which are completely incompatible since the inclusion of the #dynamiclinkfile directive in GoAsm, it has to left out of the lib build in GoAsm. Beyond that the output of GoAsm is COFF and you would use MS Lib.exe so the two assemblers can read each others static libraries. As you know GoAsm does not use import libraries so the includelib directive doesn't really apply.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

i see - well, i would not use that directive anyways
but it is nice to know how to write files so they may be built using either assembler   :bg