Posted: Mon Nov 22, 2010 2:30 am Post subject: How to link an assembly object with a c++ project
Hello,I'm trying to link an assembly program with my c++ program. I'm using NASM to generate the .obj file with the command "nasm -fobj myprogram.asm". The .obj file is created, but I'm not sure how to link this with my project. I tried adding the file to Linker->Dependencies, but I still get the error that my external assembly function is not defin开发者_如何学Goed. Maybe the .obj file is in the wrong directory(it's in the root project folder, along with the .cpp files)?
Can anyone give a simple explanation about how to link an assembly language .obj file with my project?
Thanks, -KB
Make sure you mangle the name appropriately in the assembler code.
IIRC, __stdcall is used by default in 32 bit MSVC and it prepends an underscore and appends @[bytes of arguments].
So, size_t strlen( const char *str )
, if compiled __stdcall would be mangled to
_strlen@4
.
Look here or here for more details.
精彩评论