VC++ obj file link to asm obj file with alink(not working) 
Author Message
 VC++ obj file link to asm obj file with alink(not working)

I want to access function written in nasm and called in VC++'s .cpp
file. So I did the following:
Asmfile:

  [bits 32]
global _start
_start:
   push esp
   mov ebp,esp

   ;code for calling parameter as per "C" conversion  
   pop esp
   ret

And in cpp file

extern int  start(int);
main()
{
  start(2);

Quote:
}

compiling:
  cl cas.cpp (I just want the .obj file)
  nasm _f obj asmfile.asm

linking:
  alink _oEXE  cas.obj  asmfile.obj

Is giving the following:
 ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams.
All Rights Reserved

Loading file cas.obj
Loading file as.obj
matched Externs
matched ComDefs

HELP.

Please NOTE:  I want to use a 32 bit free linker and any 32bit c++
compiler.



Mon, 25 Jul 2005 02:03:49 GMT  
 VC++ obj file link to asm obj file with alink(not working)
Your problem lies here:
extern int  start(int);

Change to:
extern "C" int  start(int);

Read about C++ name mangling.

-Matt


Quote:
> I want to access function written in nasm and called in VC++'s .cpp
> file. So I did the following:
> Asmfile:

>   [bits 32]
> global _start
> _start:
>    push esp
>    mov ebp,esp

>    ;code for calling parameter as per "C" conversion
>    pop esp
>    ret

> And in cpp file

> extern int  start(int);
> main()
> {
>   start(2);
> }
> compiling:
>   cl cas.cpp (I just want the .obj file)
>   nasm _f obj asmfile.asm

> linking:
>   alink _oEXE  cas.obj  asmfile.obj

> Is giving the following:
>  ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams.
> All Rights Reserved

> Loading file cas.obj
> Loading file as.obj
> matched Externs
> matched ComDefs

> HELP.

> Please NOTE:  I want to use a 32 bit free linker and any 32bit c++
> compiler.



Tue, 26 Jul 2005 03:27:36 GMT  
 VC++ obj file link to asm obj file with alink(not working)
Thanks for the replay post. I am getting the solution. Sorry for late replay.


Thu, 28 Jul 2005 00:56:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Link a MASM .obj file with a C .obj file

2. linking NASM-generated .obj files to VC++

3. Link Masm32 6.0 obj file with VC++ obj file. Please help me!

4. CLARION is unresolved in file d:\cw55\obj\skifer.obj

5. VC++ with masm obj files

6. Need help linking NASM .obj's to C++ obj's

7. Linking MF copiled obj's with Turbo C++ obj's

8. Help,how to link Lahey .obj with Ms .obj toget

9. Help,how to link Lanhey .obj with MS .obj together

10. Definining C++ class methods in external .ASM (OBJ) files

11. Link Error: _IntelliDateValue is unresolved in file xxxxx.obj

12. Failing to link long list of OBJ files

 

 
Powered by phpBB® Forum Software