The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: GUAN DE DIO on June 15, 2011, 06:20:25 AM

Title: Problem with a dll
Post by: GUAN DE DIO on June 15, 2011, 06:20:25 AM
Hi everybody,

        I'm working on a project in C++Builder. I want to use some code written by my in MASM, so my first idea was to create a dll with this code, and then try to use the dll in my C++Builder application.

       I created the Dll and I tested it in an MASM project and all works fine. The problem started when I have tried to convert the .lib COFF generated by MASM to OMF format to work with the dll in static mode in BCB. For that I try with implib.exe and coff2omf.exe without success, I always have the same error in the linker step (don't find external reference to ... ).

       Maybe I miss something in the creation of the dll for making work the BCB conversion tools,  I don't know.

      Have someone any idea or another alternative to obtain the .lib en OMF format?

Thanks in advance,
GUAN

       
Title: Re: Problem with a dll
Post by: Ficko on June 15, 2011, 10:22:14 AM
Hi!

Borland's C++ works very good with his "TASM" or if you need SSE LZASM (only for IDEAL).

The prefered way is to port the MASM assembly to TASM masm mode - the easier approach - or to LZASM ideal mode.
That way the source can be included into your project - no DLL needed - statically linkable.
Title: Re: Problem with a dll
Post by: GUAN DE DIO on June 15, 2011, 10:37:08 AM
Hi!

     Move the MASM code to TASM is not an option, it is a lot of code.

     If it is possible, I prefer to work with a dll, by the way, for working with a static lib I need it in omf format so I'll have the same problem. 
Title: Re: Problem with a dll
Post by: drizz on June 15, 2011, 01:28:19 PM
A static library with only import definitions (for a .DLL) can be created from a .DEF file using "implib.exe".




A static omf library can be created like this:

1) ml
2) omf2d
3) tlib

@echo off
del *.obj
del lib_omf.lib
dir /b /S .\String\*.asm > ml.rsp
dir /b /S .\Convert\*.asm >> ml.rsp
dir /b /S .\Std\*.asm >> ml.rsp
dir /b /S .\File\*.asm >> ml.rsp
dir /b /S .\Ini\*.asm >> ml.rsp
dir /b /S .\Registry\*.asm >> ml.rsp
dir /b /S .\Console\*.asm >> ml.rsp
echo ...asm to obj...
rem /omf needed for ML >= 6.15
ml /nologo /c /omf /I"\MASM32\INCLUDE" @ml.rsp
if errorlevel 1 goto mlerr
echo ...obj to lib...
FOR %%I IN (*.obj) DO omf2d %%I %%I
FOR %%I IN (*.obj) DO tlib /c lib_omf.lib +%%I
if errorlevel 1 goto liberr
del *.obj
goto end
:mlerr
echo.
echo ***ERROR***
pause
goto end
:liberr
echo.
echo ***ERROR***
pause
goto end
:end
Title: Re: Problem with a dll
Post by: GUAN DE DIO on June 15, 2011, 01:57:19 PM
Solved xD

first of all   I miss in the .hpp file the sentences extern "C" and __stdcall, it must be done in this way:

extern "C" <type> __stdcall <funtion> <arguments>

Then using the coff2omf in this way:

    coff2omf -lib:st LibMASM.lib  LibBorland.lib

And all work fine.

Thanks for the support.

GUAN