Sign in to follow this  

Using MSVC++ compiler from the command line

This topic is 3407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use the command line tools cl.exe and link.exe from the command line so I can use cygwin makefiles (best not to ask why). I've got it all working except... I'm compiling an SDL application, I'm using main() (rather than winmain()) and compiling a console application. Problem is, when I run it I always get a "Press any key to continue . . ." when my app is exiting (naturally it doesn't happen if I use winmain()). This is if I run it from microsoft visual studio, from the command line, or when double clicking it, however this behaviour gets pretty annoying. Any Idea what I'm doing wrong? I'm using the following command lines: cl.exe /nologo /c /EHsc /MDd /ZI /DEBUG /Fomain.o main.cpp link.exe /nologo /DEBUG user32.lib gdi32.lib SDL.lib /OUT:main.exe main.o Thanks for any help!

Share this post


Link to post
Share on other sites
Do some research on nmake.

nmake is the "make file" utility that comes with visual studio. Looking into that might give you a good starting point on how to use the msvc compiler/linker in gnu makefiles.

Share this post


Link to post
Share on other sites
i think you need to add /subsystem:windows to your link command line.

link /NOLOGO /SUBSYSTEM:WINDOWS main.obj SDLmain.lib SDL.lib

is what i use...


link /link will show you the link help, and you'll see:

/SUBSYSTEM:{BOOT_APPLICATION|CONSOLE|EFI_APPLICATION|
EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|
NATIVE|POSIX|WINDOWS|WINDOWSCE}[,#[.##]]

also, i think on windows SDL you can link against SDLmain.lib, and then SDL will do something like:

#define main sdlmain(..)
and then implements WinMain for you, and wraps your call to standard main(..)

anyways, good luck.
r.

Share this post


Link to post
Share on other sites
Thanks for the help.

This is a little embarrassing.

After trying out both your ideas, and about an hour or two digging about, I found that a stupid svn merge and some odd defines in the file that has main() in... means that I have a system("pause") at the end of main.

I don't really know where to hide my face.

Ah well, I know a lot more about cl.exe and link.exe than I did a few days ago thanks to this, so that's a plus I guess.

Thanks again.

Share this post


Link to post
Share on other sites

This topic is 3407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this