News:

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

A conflict between generated LIB files

Started by Hero, July 11, 2005, 05:36:26 AM

Previous topic - Next topic

Hero

Hi all
I want to ask a question about conflict between masm32 generated LIB files and VS ones.
I write a DLL using masm32.It generates an LIB files beside generated DLL files.When I use
that DLL in VS using LoadLibrary and GetProcAddr there is no problem.But When I try to use
LIB files and link it to program and use it(simillar to what I can do for VS genearted LIB files)
according to an unknown reason,the VS link error accures that say :"Unable to resolve external
symbol.....".
Why this happens?How I can solve this problem and use generated masm32 lib files in VS?

sincerely yours

hutch--

Hero,

The only thing that can produce this effect is name conflicts for library module names. Another thing to keep in mind is you must prototype the procedures as EXTERN so the mangling does not occur.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Hero

Thanks for quick reply.
But I don't get what you mean by "you must prototype the procedures as EXTERN".
This is my sample:
(I only written required codes)
testdll.asm:

      .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

LibMain proc instance:DWORD,reason:DWORD,unused:DWORD

    .if reason == DLL_PROCESS_ATTACH
      push instance
      pop hInstance
      mov eax, TRUE

    .elseif reason == DLL_PROCESS_DETACH

    .elseif reason == DLL_THREAD_ATTACH

    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

testfunc proc
invoke MessageBoxA,NULL,addr tester,addr tester,MB_OK
ret
testfunc endp

end LibMain

testdll.def:
LIBRARY testdll
EXPORTS testfunc

and my sample VS program:
//Declare header
extern "C" void testfunc();

void CTestDlg::OnBnClickedOk()
{
testfunc();
OnOK();
}


What is the problem with this code?

sincerely yours

hutch--

Quick look says it should work. Make sure of this much that you match the calling conventions in both the assembler procedure and the C ptototype you write for your C source code. This is probably what the problem is.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Hero

Thanks for help! :U
I finnaly find out waht is the problem,I should export function with "C" calling mode:
LibMain endp

testfunc proc [color=Red]C[/color]
invoke MessageBoxA,NULL,addr tester,addr tester,MB_OK
ret
testfunc endp

end LibMain

But I want o know something else know.
The generated lib file,Is only something that reference to dll file.
Is there anyway that this lib file generated and there is no need for dll file existance?

sincerely yours

Vortex

If you are usink MS link to link your object files, you will need the import library created for your DLL. Jeremy Gordon's GoLink doesn't require import libraries.

hutch--

Hero,

That cannot be done as the binary code exists in the DLL, not the import library. The import library basically holds data for the linker, not the actual binary code itself.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php