NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: soren on August 22, 2011, 12:11:58 PM

Title: gcc links automatically? but cl.exe does not (windows)
Post by: soren on August 22, 2011, 12:11:58 PM
hi, (total noob). I cant work out why when I assemble helloworld.asm (using nasm -f win32 helloworld.asm) i can then convert the object file to an exe with  simple "gcc helloworld.obj", but if i use microsofts cl.exe  i get:

helloworldasm.obj : error LNK2001: unresolved external symbol _printf
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
helloworldasm.exe : fatal error LNK1120: 2 unresolved externals


in microsfts tool i have to use the linker:
link helloworld.obj libcmt.lib

why is gcc able to act as a linker while cl.exe does not?
Title: Re: gcc links automatically? but cl.exe does not (windows)
Post by: Dumah on August 22, 2011, 07:14:27 PM
AFAIK, gcc just calls the 'ld' command to do the business.

With regard to using the lib, I think gcc just assumes everything uses libc so chucks it in. VC++ doesnt
Title: Re: gcc links automatically? but cl.exe does not (windows)
Post by: Frank Kotler on August 22, 2011, 08:32:45 PM
That sounds right. With Linux, anyway, gcc calls ld with a "correct" command line - including libc. If I call ld directly, I have to put "-lc" on the command line (if I'm using libc).

It was a long, long time ago that I last used an MS compiler. As I recall, I called cc.exe, and it called cl.exe (and other things?). If you've got a "cc.exe", it might be worth a try...

Best,
Frank

Title: Re: gcc links automatically? but cl.exe does not (windows)
Post by: soren on August 23, 2011, 02:27:36 AM
ahh ok. i wish ever class of tool (linker, compiler)  worked the same so as i didnt have to remember the different defaults and behavious.   >:(  ;D