in reply to cl.exe & _ansi.h

Will you please read A Practical Guide to Compiling C based Modules under ActiveState using Microsoft C++ and follow the instructions. If you do what it says there and it still won't work.....

You second example is just wrong. To compile hello.c with your INCLUDE and LIB env vars set, and the correct bits in your path all you need to do is:

cl hello.c

It should be that easy. Here is an approximation of what your PATH, LIB and INCLUDE env vars should look like:

C:\>set PATH Path=D:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C: +\COREL50;C:\Program Files\SSH Communications Security\SSH Secure Shel +l ;C:\Program Files\Microsoft Visual Studio .NET\Vc7\bin;C:\Program File +s\Common Files\Microsoft Shared\VSA\7.0\VsaEnv C:\>set LIB LIB=C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Lib\;d: +\tools\cl\lib\ C:\>set INCLUDE INCLUDE=C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\inc +lude\;d:\tools\cl\include\ C:\>cl hello.c Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.00.9466 for 80 +x86 Copyright (C) Microsoft Corporation 1984-2001. All rights reserved. hello.c Microsoft (R) Incremental Linker Version 7.00.9466 Copyright (C) Microsoft Corporation. All rights reserved. /out:hello.exe hello.obj C:\>hello Hello World

Here is a quick explanation of the various bits you are seeing in the command line of a linked widget like the embedded interpretter that this is all about:

cl.exe -DWIN32 -I"C:\Perl\lib\CORE" C:\Perl\lib\CORE\perl58.lib -o int +erp.exe interp.c 1 2 3 4 5 + 6
  1. cl.exe This is the MS compiler. The exe is optional as Win32 will look for a cl.exe and cl.com and cl.bat if you just type 'cl'
  2. -DWIN32 This is a define - it defines the compiler token WIN32*
  3. -I"C:\Perl\lib\CORE" This is where to look for included headers, in addition to any default locations set via the INCLUDE env var
  4. C:\Perl\lib\CORE\perl58.lib This is a compiled library that we are going to link to. While the header file typically just contains a function definition, the library code contains the real guts of the code. When you don't have all the required libs available the compiler will typically die saying can't find entry point _some_function.
  5. -o interp.exe This instructs the comiler to output the executable to interp.exe. With cl.exe if the input file is called blah.c then it will produce blah.exe by default. gcc by contrast would produce a.out if you don't specify the name
  6. interp.c This is what we are actually compiling

* DEFINES

Here is a snippet from perl.c

#if defined(WIN32) incpush(PRIVLIB_EXP, TRUE, FALSE); #else incpush(PRIVLIB_EXP, FALSE, FALSE); #endif

When we compile with -DWIN32 the WIN32 token will be defined, so the first incpush() will be compiled, while the second is simply stripped and ignored. If the WIN32 token is not defined then the reverse will happen.

cheers

tachyon