When linking asm with C++ linker complains about C++ files is not COFF.

code.obj : fatal error LNK1123:
failure during conversion to COFF: file invalid or corrupt

C file:
-----
extern void myasm(void);
void main(void)
{
myasm();
}

ASM (masm) file:
--------
.586
.MODEL FLAT,STDCALL
OPTION SCOPED
OPTION CASEMAP:NONE

.code

PUBLIC  _myasm

_myasm proc
    ret
_myasm endp 

END

--------
$ bcc32 -c code.cpp
(no errors - got code.obj)

$ ml /c /coff /Cp /Zi asm2c.asm
(no errors - got asm2c.obj)

$ link /debug /subsystem:console code.obj asm2c.obj /OUT:done.exe

ERROR...

Please help, thanks.

Posted on 2008-01-18 15:54:14 by sittingduck
Borland/Inprise/Codegear/whatevername utils use OMF format. Get a better C++ compiler, like the free Visual C++ Express from Microsoft.
Posted on 2008-01-18 16:08:31 by f0dder

Get a better C++ compiler, like the free Visual C++ Express from Microsoft.



Done that.  8)
Can you point out some good sites or books with info about linking Masm & Visual C++?
Posted on 2008-01-19 15:48:46 by sittingduck
Good :) - you now have better ISO C++ conformance, and better code generation.

There should be info here on this site about linking the two, try using the forum search for "c++" (and do use the quotes!). One hit that might help you is this one.
Posted on 2008-01-20 03:05:20 by f0dder
sittingduck,

You can try Agner Fog's Object file converter tool. It can convert OMF to MS COFF and vice versa. I cannot guarantee you a result with 100% success but you should try it :

http://agner.org/optimize/#objconv
Posted on 2008-01-20 12:30:13 by Vortex

sittingduck,

You can try Agner Fog's Object file converter tool. It can convert OMF to MS COFF and vice versa. I cannot guarantee you a result with 100% success but you should try it :

http://agner.org/optimize/#objconv

That'll probably work too, but considering there's better (and free!) compilers around than Turbo C++, the smartest choice is moving to one of those :)

(Agner's tool could be useful if you want to play with D, though).
Posted on 2008-01-20 12:48:04 by f0dder