views:

603

answers:

4

Attempting to do something very simple - compile basic win 32 c programs through windows cmd. This is something I should be able to do myself, but I am just so stuck here..

I keep stumbling into weird problems, vague errors. I dunno whether I should go into details. Using tcc ( tiny c compiler)

  1. One simple hellowin.c example from a book required winmm.lib. How do I import it ? can someone give me the exact command for gcc/tcc /any command line compiler for windows(except cygwin) ? I did try various options after reading help , but it kept giving me a can't find stupid error.

  2. a sample from platform sdk that I tried to compile gave a - winnt.h "( expected" error. this after a #define _M_IX86 . what it means ?

  3. any general guide for compiling c programs for windows(win32 api) through command line ? . explaining what all should be #defined ..etc..

I have googled a lot but most of the c compiling guidelines for win32 programs focus on vb .I wanna do it manually , on the command line.

Thanks

A: 

Sounds like the kind of compiler that might be looking for INCLUDE and LIB paths in the environment. If you do "set" on the command line and don't see those vars listed, you could try setting them to the paths your compiler is using. Not sure where you would have installed this tcc tool, but look for directories named 'include' and 'lib' and try assigning those to the aforementioned environment variables.

JustJeff
A: 

You can try gcc from equation.com. It's a mingw wrapped compiler, but you don't have to worry about mingw: just download, install and use. There's no IDE either.

The download page is at http://www.equation.com/servlet/equation.cmd?fa=fortran.

pmg
A: 

If I create a new project using Visual Studio it #defines the following preprocessor symbols using compiler command-line options:

  • WIN32
  • _WINDOWS
  • one of either _DEBUG or NDEBUG
  • UNICODE and _UNICODE (although the Windows headers and libraries also support non-Unicode-enabled applications, if your compiler doesn't support Unicode).

http://bellard.org/tcc/tcc-doc.html says "For usage on Windows, see also tcc-win32.txt".

ChrisW
+1  A: 

Download the Windows PlatformSDK and it comes with its own command line compiler. It creates a shortcut Start->Programs->... to open a command prompt for either 32bit or 64bit. Select the 32bit variant and you get a fully initialized command prompt with compiler in your PATH and all INCLUDE, LIB and LIBPATH set.


cmd> cl hello.c


This should give you hello.exe. For more help on compiler "cl /?", for linker "link /?"

hackworks