0

I am working on a big MASM project (I've Compiled my MASM code using the ML compiler under VS 2019) , and I would like to call a C function I wrote, within my MASM code. I googled it a lot , but I couldn't find anything useful. How can I achieve that?

When I just tried to add my C source-code to the project and rebuild it , I got a bunch of linking errors (LNK2019) , like these:

LNK2019 unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT

LNK2019 unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW

LNK2019 unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l

Here is a screenshot of the errors window

  • Maybe related to this? https://stackoverflow.com/questions/44083907/simple-assembly-program-on-visual-studio-2017/44090648#44090648 and this: https://stackoverflow.com/questions/33721059/call-c-standard-library-function-from-asm-in-visual-studio/33724617#33724617 . This is a guess since you didn't provide your code. – Michael Petch May 25 '19 at 14:54

1 Answers1

0

Answering my question

I've finally figured out a way to do this.

Create a Static library (.lib) from your C/C++ module.

Properies -> Project Defaults -> Configuration Type -> change to .lib

and then, In your masm code , add these lines:

includelib your_generated_lib.lib

(Be sure to add your lib file to the directory of your masm code)

and add prototypes to your functoins like this:

function_name PROTO C :DWORD   ;(Just an Example )

Hope it helps,

Omer