Compiling SDLmain.lib,SDL.lib under Win32

I don’t have Visual C++, but I do have the Platform SDK, .NET SDK, and Visual
C++ Toolkit command-line compiler (this should be enough for SDLmain.lib,
right?). I’ve been able to compile programs and link them with the precompiled
binaries, but I want to be able to write to the console rather than stdout.txt
and stderr.txt. I’ve read that this requires a recompile of the SDL libraries,
but I can’t seem to get it to work. For SDLmain.lib, I get unreolved externals
for SDL_Init, SDL_Quit, SDL_SetModuleHandle, SDL_GetError, and I think a one or
two more functions. I’ve looked at the VC++ project files in a text editor and
I think I’m including and defining everything, but I still get these linker
errors. I haven’t tried SDL.lib yet because I don’t have the DirectX SDK yet.
Can someone help me out?

Luke wrote:

I don’t have Visual C++, but I do have the Platform SDK, .NET SDK, and Visual
C++ Toolkit command-line compiler (this should be enough for SDLmain.lib,
right?). I’ve been able to compile programs and link them with the precompiled
binaries, but I want to be able to write to the console rather than stdout.txt
and stderr.txt. I’ve read that this requires a recompile of the SDL libraries,
but I can’t seem to get it to work.

It doesn’t require that you recompile the binaries. It only requires
that you make your application a Win32 console application in the
compiler options. The Visual C++ compiler option is:

/D “_CONSOLE”

You also DON’T want the option:

/D “_WINDOWS”

because that option makes your SDL app run in a window with all output
put into stdout and stderr text files. I don’t know what happens when
you try to use both, because by default Visual C++'s IDE doesn’t do
that. Technically, you could #define _WINDOWS or #define _CONSOLE
instead under some #if statements if you want to have in-code conditions
for which you use the console or not.

So you can use the same binaries, just making your app a console app.

-TomT64

It doesn’t require that you recompile the binaries. It only requires
that you make your application a Win32 console application in the
compiler options. The Visual C++ compiler option is:

/D “_CONSOLE”

Ah, that did it. Except rather than defining _CONSOLE, I have to
specify /SUBSYSTEM:CONSOLE to the linker and it works. If I don’t use
the /SUBSYSTEM parameter, it complains of a missing entry point. I was
using /SUBSYSTEM:WINDOWS before, because it just worked (except for stdout),
but it never occurred to me to change it. Anyway, thanks a bunch.