jack_yangyue
asked on
How to link obj written by assembly in VC?
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.
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.
ASKER
The problem can not be solved after i add obj to the project.
ASKER
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.
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.
Show some of your asm code snippet.
ASKER
%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;
...
%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;
...
try to change _SAD_Macroblock_mmx:->_SAD _Macrobloc k_mmx@16:
ASKER
The same error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much!I will try it again.
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:functio n
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:functio
Sorry Jack I ment nasm -f win32... . I use nasm too much for linux.
ASKER
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?
maybe, not sure:(
ASKER
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*.
Try to add the OBJ file, which outputted by NASM, into your VC project.