Dr A A Olowofoyeku wrote:
Peter Gerwinski peter@gerwinski.de wrote:
Sounds mostly okay - except that with Win32, a DLL does not need to have the extension '.dll' (for example, Win32 device drivers are just DLLs with the same interface, and with the extension '.drv' ). A Win32 DLL can have any extension, or no extension at all. Thus it might be that the extension will need to be specified. On the other hand, I suppose that perhaps GPC can presume the extension '.dll' unless another extension is suppled. However, how do you then deal with a case where someone has written a DLL but does not want to give it any extension?
Let GPC first search for the name 'foo' as given, second for 'foo.dll' or 'libfoo.so' (depending on the OS) and last for 'libfoo.a'.
Perhaps we are talking at cross-purposes here! The Win32 problem will occur not a compile or link time, but at runtime, when the program is trying to link to the DLL. I am not sure whose job it is to search for the DLL at this point - whether it is the compiler's job or the OS (I suspect that it is the job of the OS which should then raise an exception if it cannot find the DLL).
Indeed, it's not the compiler that searches for the libraries, but the (static or dynamic) linker. As it is now, `{$L filename.ext}' will:
- pass `filename.ext' to the linker, if `.ext' is a known linker extension, currently `.o', `.a', `.so', `.lnk',
- pass `-l filename' to the linker if `.ext' is missing. The linker will then search for a (static or dynamic) library called `filename' with the appropriate extension (i.e., `.a' for static and `.so' for dynamic libraries -- I suppose the windoze linker will search for `.dll' rather than `.so'),
- pass a filename with any other extension to the compiler (with automake). The most common case here is `.c' to compile and link C code.
So, this mechanism currently does not allow arbitrary linker extensions. We could turn it around, so that only known source extensions (`.pas', `.p', `.c', `.cc', `.i', `.S', perhaps `.f' (Fortran?) etc.) are passed to the compiler, and all other extensions to the linker.
This would then only prevent a linker file with a source extension (but who would want to give a binary such an extension ;-), and without an extension (because that's reserved for `-l'). If the latter is a real issue, we might have to change the syntax for the second case (`{$L foo}' -> `-l foo'), which I'd consider unfortunate, since it's the most common one besides `{$L foo.c}'.
BTW, using `-l foo' (or `{$L foo}' or later "external 'foo'") is preferable over `foo.a' (or `{$L foo.a}', or "external 'foo.dll'", etc.) for several reasons: `-l' will search the library path (`-L'), will find static or dynamic libraries, taking into account the `-static' switch, and can use the appropriate extensions (e.g. `.so' or `.dll').
Frank
-- Frank Heckenbach, frank@fjf.gnu.de, http://fjf.gnu.de/ GPC To-Do list, latest features, fixed bugs: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html