• Welcome to Jose's Read Only Forum 2023.
 

Minimize Program Size By Eliminating The C Runtime Library

Started by Frederick J. Harris, March 23, 2016, 01:17:52 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

James C. Fuller

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....


@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