Prof. Abimbola A. Olowofoyeku (The African Chief) wrote:
On 7 Mar 2004 at 20:21, Waldek Hebisch wrote:
[...]
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
It is a big problem. Windows dlls export only routines. Data is normally internal to the dll itself (which is actually a special form of executable rather than a proper library) and must be retrieved in other ways (best by access routines). C programmers I apparently can use "__delcspec(dllimport)" to get access to dll data - e.g., #define _DL_IMPORT __delcspec(dllimport) _DL_IMPORT extern void *(*my_malloc)(int sz);
I got this example from the documentation of "a2dll" which converts a static library to a Windows dll. I wouldn't have a clue as to whether this can be done with GPC or not, and, if it can be done, how to do it. Assuming it could be done, it would be wonderful.
I looked at "a2dll" and AFAIKS the procedure works for GPC too:
bash-2.04$ i386-pc-mingw32-gcc --shared -Wl,--export-all -o libgpc.dll -Wl,--output-def=libgpc.def -Wl,--out-implib=libgpc.dll.a -Wl,--whole-archive libgpc.a -Wl,--no-whole-archive Creating library file: libgpc.dll.a bash-2.04$ i386-pc-mingw32-gpc -c hello.p bash-2.04$ i386-pc-mingw32-gcc hello.o libgpc.dll.a 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) bash-2.04$ wine a.exe Hello World bash-2.04$
So probably "dllwrap" used incorrect options. The executable is still large, but after stripping gets much smaller: bash-2.04$ ls -l a.exe -rwxr-xr-x 1 hebisch users 216302 Mar 8 15:31 a.exe bash-2.04$ i386-pc-mingw32-strip a.exe bash-2.04$ ls -l a.exe -rwxr-xr-x 1 hebisch users 4096 Mar 8 15:38 a.exe