How to link obj written by assembly in VC?

jack_yangyue
jack_yangyue used Ask the Experts™
on
Platform: win2000pro
Languages: VC6.0++
Describe:
In my project i need to link obj files written by NASM assembly. The interface of C and assembly is correct. But when i try to link. There comes errors like these:

LINK :
mot_est_comp.obj : error LNK2001: unresolved external symbol _InterpolateImageMmx@20
mot_est_mb.obj : error LNK2001: unresolved external symbol _SAD_Macroblock_mmx@16
text_code_mb.obj : error LNK2001: unresolved external symbol _fdct_mmx@4
release\pacmp4.ax : fatal error LNK1120: 3 unresolved externals

Please help me.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
>> i need to link obj files written by NASM assembly
Try to add the OBJ file, which outputted by NASM, into your VC project.

Author

Commented:
The problem can not be solved after i add obj to the project.

Author

Commented:
The whole information is:

Linking...
LINK : warning LNK4108: /ALIGN specified without /DRIVER or /VXD; image may not run
   Creating library pacmp4.lib and object pacmp4.exp
mot_est_comp.obj : error LNK2001: unresolved external symbol _InterpolateImageMmx@20
mot_est_mb.obj : error LNK2001: unresolved external symbol _SAD_Macroblock_mmx@16
text_code_mb.obj : error LNK2001: unresolved external symbol _fdct_mmx@4
release\pacmp4.ax : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Commented:
Show some of your asm code snippet.

Author

Commented:
%define MB1 esi
%define MB2 edi
%define MIN_ERR ebx
%define ROW ecx
%define SAD edx
%define MB1_ROW_INC ebp+16

BITS 32

GLOBAL _SAD_Macroblock_mmx ;called by C

SECTION .text
ALIGN 8

_SAD_Macroblock_mmx:
     push ebp;
     mov ebp, esp;

     push ebx;
     ...

Commented:
try to change _SAD_Macroblock_mmx:->_SAD_Macroblock_mmx@16:

Author

Commented:
The same error
Commented:
I can do this.
I use extern "C" void     SAD_Macroblock_mmx(); in my cpp.
with asm code:
GLOBAL _SAD_Macroblock_mmx ;called by C
_SAD_Macroblock_mmx:
There no error for me.
I use Win2k+VC6.0 also.

Author

Commented:
Thank you very much!I will try it again.

Commented:
When you use nasm with win32 you should use the elf type and not obj.

nasm -f elf ....
This format is supported by nasm-0.98
Now for the asm source.

You have the Global correct but, nasm does not need the extra "_"  So if in your "C" code you use the function
 SAD_Macroblock_mmx(....) then do:                       GLOBAL SAD_Macroblock_mmx:function

Commented:
Sorry Jack I ment nasm -f win32... . I use nasm too much for linux.

Author

Commented:
I can do it by building a new project. But in my project the problem are not resolved. Does it occur with some setting problems?

Commented:
maybe, not sure:(

Author

Commented:
Thank everyone for your help. I have succeeded to solve the linkage problem by changing the setting of calling convention of project-settings-C/C++ to _cdecl*.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial