1

I want to create a simple application in Assembly (with NASM) that will get the command line arguments. For now I use extern _GetCommandLineA and call _GetCommandLineA to call the function. I compile the code and get the object file from NASM. Now I wanna use GCC to link and create the EXE. I don't want to use the standard libraries, so I use this command to build the executable:

gcc test.obj -s -nostartfiles -nostdlib -nodefaultlibs -o test.exe

It gets me an Undefined reference to GetCommandLineA error and, as a beginner in ASM, I don't know why? Some help would really be appreciated. Thanks in advance!

4

1 回答 1

1

GetCommandLineAGetCommandLineWkernel32.dll其中定义,与大多数 Windows API 一样,使用WINAPI (stdcall) 调用约定

为了从程序集中调用此函数,您需要指定完全“装饰”的符号名称,在这种情况下_GetCommandLineA@0

_GetCommandLineA在您的程序集文件中替换为_GetCommandLineA@0

于 2012-06-05T19:36:59.527 回答