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
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.
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.
BTW: the "a2dll" program very helpfully provides a list of the data items that it thinks it found in libgpc.a while converting it to a dll - as follows; Counter Cparametersdummy Currentreturnaddr Currentreturnaddrcounter DllHandle __GPC_RTS_VERSION_20030830__ _p_AbortOnError _p_CParamCount _p_CParameters _p_CurrentStdin _p_DirSeparatorVar _p_EOLnResetHack _p_Environment _p_ErrorAddr _p_ErrorFD _p_ErrorFileName _p_ErrorMessageString _p_ExitCode _p_FPE_DECOVF_TRAP _p_FPE_FLTDIV_TRAP _p_FPE_FLTOVF_TRAP _p_FPE_FLTUND_TRAP _p_FPE_INTDIV_TRAP _p_FPE_INTOVF_TRAP _p_FPE_SUBRNG_TRAP _p_FakeHighLetters _p_FileAssociation _p_FileMode _p_FirstNonOption _p_ForceDirectFiles _p_FormatStringTransformPtr _p_FreeMemPtr _p_GetMemPtr _p_GetOptErrorFlag _p_HasOptionArgument _p_HeapChecking _p_HeapHigh _p_HeapLow _p_InOutRes _p_InOutResCErrorString _p_InOutResString _p_InitProc _p_Input _p_LowInteger _p_OpenErrorCode _p_OptionArgument _p_Output _p_RTSWarnFlag _p_RandIntPtr _p_RandRealPtr _p_RandomizePtr _p_ReAllocMemPtr _p_SIGABRT _p_SIGALRM _p_SIGBUS _p_SIGCHLD _p_SIGCONT _p_SIGEMT _p_SIGFPE _p_SIGHUP _p_SIGILL _p_SIGINFO _p_SIGINT _p_SIGIO _p_SIGIOT _p_SIGKILL _p_SIGLOST _p_SIGPIPE _p_SIGPOLL _p_SIGPROF _p_SIGPWR _p_SIGQUIT _p_SIGSEGV _p_SIGSTKFLT _p_SIGSTOP _p_SIGSYS _p_SIGTERM _p_SIGTRAP _p_SIGTSTP _p_SIGTTIN _p_SIGTTOU _p_SIGURG _p_SIGUSR1 _p_SIGUSR2 _p_SIGVTALRM _p_SIGWINCH _p_SIGXCPU _p_SIGXFSZ _p_SIG_DFL _p_SIG_ERR _p_SIG_IGN _p_SeedRandomPtr _p_StdErr _p_TtyDeviceNameVar _p_UnknownOptionCharacter info2 pNetApiBufferFree pNetUserEnum set_result_Filename_0 set_result_Gpc_151 uid2
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/