I am new to assembly and I have a bunch of .c files and a .asm file which I would like to compile to produce a .exe file. I was able to use the command here to generate the obj file correctly. However I have not done the linking because I am not really sure of the process. Do I add the .c files to the linking process? If yes, how? There does not seem to be a lot of helpful answers on microsoft
Asked
Active
Viewed 439 times
1
-
The C files would have to be compiled into object files, for which I suppose `cl` would be suitable (part of Microsoft Visual C++, not of MASM). – Michael Feb 20 '19 at 14:21
-
I saw that [here](https://learn.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line?view=vs-2017) but is there a way to compile them all together? Like if I do the cl for the c files seperately, and the ml for the asm file, its all for one executable – droidnoob Feb 20 '19 at 14:27
-
Not that I know of. But is that really a problem? It's not like you would sit and write each command every time you build. – Michael Feb 20 '19 at 14:31
-
no I mean if I do 'cl /W4 file1.c file2.c file3.c /link /out:program1.exe' and 'link code.obj /SUBSYSTEM:console /out:program1.exe /entry:clear', would it compile to one exe or two? – droidnoob Feb 20 '19 at 14:34
-
1One, because you use the same filename in both commands, so the second command overwrites the executable generated by the first command. It's a waste of time to link twice though. Either tell `cl` to link and include the object file generated by MASM on the command line, or tell `cl` to only generate object file by using the `/c` option and removing the `/link` option. – Michael Feb 20 '19 at 14:43
-
okay thank you, will try this out – droidnoob Feb 20 '19 at 14:53