Prof. Abimbola A. Olowofoyeku (The African Chief) wrote:
On 7 Mar 2004 at 9:47, Claudiozm@aol.com wrote:
I compiled two versions of 'Hello World!', one in C and the other in Pascal in the ctgwin environment, as follows:
C source hello.c: int main() {printf("Hello World!\n");} command line: gcc hello.c -o helloc.exe
Pascal source: program Hello; begin writeln('Hello World!') end. command line: gpc hello.pas -o hellopas.exe
The sizes of the binaries I obtained were, respectively (copied from the DOS prompt dir command):
HELLOC EXE 11.296 bytes HELLOPAS EXE 283.531 bytes
Why the sizes of these files are so different?
This is a FAQ. The gpc executable is so big because the whole of the RTS (libgpc.a) has to be linked.
What must be done in order to obtain a hellopas.exe file of reasonable size?
Not much that you can do at the moment.
The size may be much smaller if the runtime is made into shared library (dll). On Linux this is very simple: Copy libgpc.a to a working directory ar x libgpc.a gcc -shared *.o -o libgpc.so
Then libgpc.so may be used in place of libgpc.a. In principle similar thing should work on Windows:
i386-pc-mingw32-x libgpc.a rm libgpc.a i386-pc-mingw32-dllwrap --export-all-symbols --output-lib=libgpc.a --dllname=gpc.dll
that creates gpc.dll and the import library libgpc.a, but linking hello.exe fails. Appearently references to functions are resolved, but data gives unresloved references:
i386-pc-mingw32-gcc hello.o libgpc.a -o hello.exe Info: resolving __p_stdout by linking to __imp___p_stdout (auto-import) Info: resolving __p_InOutRes by linking to __imp___p_InOutRes (auto-import) Info: resolving ___GPC_RTS_VERSION_20021111__ by linking to __imp____GPC_RTS_VERSION_20021111__ (auto-import) fu000001.o(.idata$3+0xc): undefined reference to `libgpc_a_iname' fu000003.o(.idata$3+0xc): undefined reference to `libgpc_a_iname' fu000005.o(.idata$3+0xc): undefined reference to `libgpc_a_iname' nmth000000.o(.idata$4+0x0): undefined reference to `_nm___p_stdout' nmth000002.o(.idata$4+0x0): undefined reference to `_nm___p_InOutRes' nmth000004.o(.idata$4+0x0): undefined reference to `_nm____GPC_RTS_VERSION_20021111__'
I am not an export on Windows linking, so I do not know if the problem is deep or a trivial one.