Building a dll in Visual Studio 2005

Started by PeterRod, November 11, 2008, 01:19:31 PM

Previous topic - Next topic

PeterRod

Anyone out there using Visual Studio 2005 to build a dll ?
If so can you please help.

I have a MASM app (Dynamo.asm) that was coded in VS 2005 as a console app. It has been debugged and is working properly.
I want to change it to a dll so it can be used in a vb.net GUI app.
This is my first attempt at doing a dll in MASM.
I would like to use VS2005 as my IDE for dll and console apps.
I created two export functions in the app and created a .def file as suggested in the MASM32 dll tutorial.

I cannot get the dll to assemble/link properly in VS2005.
Here is what I did:
From the project property pages:
Configuration Properties / General  / Project Defaults / Configuration Type / changed to DynamicLinkLibrary
                                     this  adds  /DLL to the link command line
Configuration Properties / Linker / Input / Module Definition File / added the .def file with full pathname
                                     this  adds /DEF:"full pathname.def" to the link command line
Configuration Properties / Linker / System / SubSystem / changed to /SUBSYSTEM:WINDOWS
No Manifest is also selected.
I made no changes in the assembler options or debug options.

Following is the command line from VS2005 linker :
/OUT:"C:\Documents and Settings\PETER\My Documents\Visual Studio 2005\Projects\AsmPgms\Debug\Dynamo.dll" /NOLOGO /LIBPATH:"C:\masm32\lib" /DLL /MANIFEST:NO /DEF:"C:\Documents and Settings\PETER\My Documents\Visual Studio 2005\Projects\AsmPgms\debug\Dynamo.def" /DEBUG /PDB:"c:\Documents and Settings\PETER\My Documents\Visual Studio 2005\Projects\AsmPgms\debug\Dynamo.pdb" /SUBSYSTEM:WINDOWS /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Following is the command line from VS2005 assembler :
ml.exe /c  /nologo /Fo"Debug\Dynamo.obj" /Fl"Dynamo.lst" /I "'C:\Documents and Settings\PETER\My Documents\Visual Studio 2005\Projects\AsmPgms'" /I "C:\masm32\include" /W3 /Zi /errorReport:prompt  /Ta

This is the .def File
LIBRARY Dynamo
  EXPORTS Hook
  EXPORTS Testip


When I build the project in VS2005 I get the following error:
 
error LNK2001 : unresolved external symbol Testip in Dynamo.def

If I change the .def file to
LIBRARY Dynamo
  EXPORTS Hook
I get the dll to assemble / link in VS2005 but when the Hook function is called from vb.net the app crashes.

If I change the .def file to
LIBRARY Dynamo
  EXPORTS Testip
I get error LNK2001 : unresolved external symbol Testip in Dynamo.def



If I manually run the following Makeit.bat file from the \Visual Studio 2005\Projects\AsmPgms\debug directory I get it to assemble / link and both the Hook and Testip functions work properly in the vb.net app.

@echo off
if exist Dynamo.obj del Dynamo.obj
if exist Dynamo.dll del Dynamo.dll
\masm32\bin\ml /c /coff Dynamo.asm
\masm32\bin\Link /SUBSYSTEM:WINDOWS /DLL /DEF:Dynamo.def Dynamo.obj

dir Dynamo.*
pause

I suspect that VS2005 is not doing the exported functions properly.
I am probably missing something in the property pages configuration or ???

Thanks in advance
PeterRod

PeterRod

Strange.
I scrapped the old VS2005 project and redid a new project with the same name.
The property pages are configured the same way.
This time everything works just fine.
I get the .dll , .exp and .lib files as expected.
The exported functions also work as expected.
!!! don't know why !!!

PeterRod

askm

Guess that

the compiler+linker wanted 'Dynamo' to be a reserved word until it

saw that you really wanted to use it ...

Mark Jones

Quote from: PeterRod on November 11, 2008, 06:16:54 PM
Strange...This time everything works just fine.

When this happens, I usually blame it on Solar Flares. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08