I make a dll in c++. My asm program uses this dll.
Well, this is the question:
if I make a lib instead a dll, can i including it in the final asm program? so no external files are necessary.
Posted on 2005-07-28 16:11:50 by The Morlok
Sure. If it's already working dinamically with an import library, all you have to do is link it statically instead and it will work too. Check out LINK's command line switches to know how to do this.
Posted on 2005-07-28 16:30:46 by QvasiModo
this is a example:

mylib.lib (c++) ----->>>>>>

extern hello();

// do nothing


my asm program ----->>>>

includelib "mylib.lib"
hello? ?PROTO C

...nice code

invoke hello

when i try to compile got the fatal >>>>>
? ? ?fatal error LNK1120: 1 unresolved externals

where is the problem ?

THANKS for the reply.

bye, morlok

Posted on 2005-07-28 17:57:45 by The Morlok
.lib format incompatibility?

I personally prefer small ASM fuctions inside a DLL, and large C++ projects inside an EXE. No problems; easy to debug, maintain and update.
Posted on 2005-07-28 18:03:44 by ti_mo_n
Morlok, calling convention and naming conventions...

.asm : cfunc PROTO C :DWORD
.cpp : extern "C" cfunc(int parm1) {...}

- the thing to note here is the `extern "C"', which specifies that you want C-style linkage (and not C++ style linkage with C++ name mangling). You could also use STDCALL for the C++ function, but the syntax differs between compilers. Which compiler do you use?
Posted on 2005-07-28 19:25:51 by f0dder
thaks for the replies.
I use Microsoft Visual C++ 6.0
If i use .cpp : extern __stdcall cfunc() {....}, the error is:

LIBCD.lib(exsup.obj) : error LNK2005: __global_unwind2 already defined in except.lib(Exchdlr.obj)
LIBCD.lib(exsup.obj) : error LNK2005: __local_unwind2 already defined in except.lib(Exchdlr.obj)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Myprogr.exe : fatal error LNK1120: 1 unresolved externals
if put .cpp : extern "C" cfunc(){...}, the error is:

error C2059: syntax error : 'string'
Error executing cl.exe.

Posted on 2005-07-29 04:35:55 by The Morlok
The "..." means "your code here" :)

extern "C" void cfunc();

void cfunc()
// do stuff


extern "C" void cfunc()
// do stuff

Also, you should use "cl /c file.cpp" - the '/c' tells cl.exe not to invoke link.exe.
Posted on 2005-07-29 09:01:18 by f0dder