Author Topic: Minimize Program Size By Eliminating The C Runtime Library  (Read 19696 times)

0 Members and 1 Guest are viewing this topic.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: Minimize Program Size By Eliminating The C Runtime Library
« Reply #30 on: March 28, 2016, 05:18:44 PM »
Fred,
  Just pass the file name no ext and a couple other libraries you might want.
I prefer to use #pragmas in the source for other libraries.
#pragma comment(lib,"winmm.lib")

example:
FRED.BAT Demo4

It is VS Studio 2015 Community and 64bit now but you can un REM the XTYPE=x86 and REM the XTYPE=x86_amd64 for 32bit.
I don't do 32 bit any more so....

Code: [Select]
@setlocal enableextensions enabledelayedexpansion
@ECHO OFF

SET F=%~nx1
IF EXIST "%F%.cpp" (
  SET FN="%F%.cpp"
  GOTO start
)
GOTO usage

:start
REM 32 bit
REM SET XTYPE=x86

SET XTYPE=x86_amd64
CALL "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%


REM cl %FN%  /O1 /Os /GS- /Zc:sizedDealloc- /link TCLib.lib kernel32.lib user32.lib %2 %3
cl %FN%  /O1 /Os /GS- /Gs9999999 /Zc:sizedDealloc- /link /STACK:0x100000,0x100000 TCLib.lib kernel32.lib user32.lib %2 %3
:cleanup
ECHO Finished!
IF EXIST "%F%.obj" del "%F%.obj"
IF EXIST "Strings.obj" del "Strings.obj"

GOTO done

:usage
ECHO **************************************************************
ECHO  Usage:  FRED.BAT MainFile  no ext .cpp assumed
ECHO **************************************************************
:done