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!
GetCommandLineAandGetCommandLineWare defined inkernel32.dllwhich, like most of the Windows API, uses the WINAPI (stdcall) calling convention.In order to call this function from assembly, you will need to specify the fully “decorated” symbol name, in this case
_GetCommandLineA@0Replace
_GetCommandLineAin your assembly file with_GetCommandLineA@0