Discussion:
Creating Dos/4gw Dynamic Link Libraries?
(too old to reply)
Johann 'Myrkraverk' Oskarsson
2018-01-01 12:57:38 UTC
Permalink
Dear Open Watcom,

How do you create dynamic link libraries for Dos/4gw? So far
I have this source code.

// file: foo.h
char * __export foo( void );

// end: foo.h

// file: foo.c

#include "foo.h"

char * __export foo( void ) {
return "bar";
}
// end: foo.c

and this make file.

## file: Makefile

foo.dll: foo.obj
wlink system 386 dll option map name foo file foo

foo.obj: foo.c
wcc386 -bt=386_dll -6r foo.c

## end: Makefile

Wlink tells me it's

creating DOS/4G dynamic link library

so I know I have most of the steps correct. However,

file foo.obj: undefined symbol __CHK

(slightly edited)

How do I get rid of that undefined symbol? If I link with
the C library, clib3r, it finds __CHK but complains about
a missing main_. Do I need a main() in a DLL? Will that
not conflict with the application's main()?
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Frank Beythien
2018-01-01 20:16:25 UTC
Permalink
Post by Johann 'Myrkraverk' Oskarsson
Dear Open Watcom,
How do you create dynamic link libraries for Dos/4gw?  So far
I don't find DOS/4G DLLs mentioned in the docs, but I don't program Dos
any more.

It would help if you posted a minimal (compiling!) example with the
complete wcc386 and wlink cmdlines output to see which version you are
using.

CU/2
Frank
Johann 'Myrkraverk' Oskarsson
2018-01-01 23:16:17 UTC
Permalink
Post by Frank Beythien
Post by Johann 'Myrkraverk' Oskarsson
Dear Open Watcom,
How do you create dynamic link libraries for Dos/4gw? So far
I don't find DOS/4G DLLs mentioned in the docs, but I don't program
Dos any more.
See the Linker Guide, The OS/2 Executable and DLL File Formats, of
all places.

I have found no explicit examples though. And the message I included
in my original post shows that Open Watcom (thinks it) knows how to
make Dos/4G DLLs.
Post by Frank Beythien
It would help if you posted a minimal (compiling!) example with the
complete wcc386 and wlink cmdlines output to see which version you are
using.
What do you mean? The makefile I listed shows the explicit wlink
command. I am using Open Watcom 1.9 (in DOSBox for this exercise).

I was missing the -bd option when compiling foo.c, this edited makefile
(below) shows a new error,

Error! E2028: __DLLstart_ is an undefined reference.
Error! E2028: main_ is an undefined reference.

It ends with:
file clib3r.lib(cmain386.c): undefined symbol main_
and does not list explicitly what links to __DLLstart_.

Do I need both __DLLstart() and main()? How do I link
in __DLLstart()? Or do I need to define it myself?

Again, won't main() in the DLL conflict with my application's main()?

## file: Makefile

foo.dll: foo.obj
wlink system 386 dll option map name foo file foo

foo.obj: foo.c
wcc386 -bd -6r foo.c

## end: Makefile
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Frank Beythien
2018-01-02 12:47:11 UTC
Permalink
Post by Johann 'Myrkraverk' Oskarsson
Post by Frank Beythien
Post by Johann 'Myrkraverk' Oskarsson
Dear Open Watcom,
How do you create dynamic link libraries for Dos/4gw?  So far
I don't find DOS/4G DLLs mentioned in the docs, but I don't program
Dos any more.
See the Linker Guide, The OS/2 Executable and DLL File Formats, of
all places.
I have found no explicit examples though.  And the message I included
in my original post shows that Open Watcom (thinks it) knows how to
make Dos/4G DLLs.
I don't think so as neither the guides nor the wlink.lnk file with all
system definitions for linking has an entry for Dos/4g dlls.
Here:
http://www.tenberry.com/dos4g/watcom/4gwtable.html
it shows DLLs are only possible with the $999 price tag and not with the
watcom included version 1.97.
Post by Johann 'Myrkraverk' Oskarsson
Post by Frank Beythien
It would help if you posted a minimal (compiling!) example with the
complete wcc386 and wlink cmdlines output to see which version you are
using.
What do you mean?  The makefile I listed shows the explicit wlink
command.  I am using Open Watcom 1.9 (in DOSBox for this exercise).
Why can't you provide the terminal output from running wcc386 ...
and the full source code so it gets reproducable for anyone who wants to
help?

CU/2
Frank
Johann 'Myrkraverk' Oskarsson
2018-01-03 09:01:03 UTC
Permalink
Post by Frank Beythien
I don't think so as neither the guides nor the wlink.lnk file with all
system definitions for linking has an entry for Dos/4g dlls.
http://www.tenberry.com/dos4g/watcom/4gwtable.html
it shows DLLs are only possible with the $999 price tag and not with
the watcom included version 1.97.
Indeed. I only discovered that *after* making a successful compile,
see below.
Post by Frank Beythien
Post by Johann 'Myrkraverk' Oskarsson
Post by Frank Beythien
It would help if you posted a minimal (compiling!) example with the
complete wcc386 and wlink cmdlines output to see which version you
are using.
What do you mean? The makefile I listed shows the explicit wlink
command. I am using Open Watcom 1.9 (in DOSBox for this exercise).
Why can't you provide the terminal output from running wcc386 ...
and the full source code so it gets reproducable for anyone who wants
to help?
Because my very first message included the full source code with repro-
ducible makefile. You're asking for something that's already there.

As for terminal output, I have yet to see DOSBox allow me to copy and
paste text. Yes, I'm running the compiler also in DOSBox. I'm not on
OS/2, Windows or Linux.

Here is the rest (below) for a fully compiling but nonfunctional
example.

By adding the option undefok to the DLL link options, I managed to com-
pile the DLL, but when I try to run it, I get

DOS/4GW error (2302): DLL modules not supported
DOS/4GW error (2301): can't find foo.foo_ - referenced from BAR
DOS/4GW fatal error (1313): can't resolve external references

So for the most part, Open Watcom does know how to make DOS/4GW DLLs,
but (of course) can't run them. There's no way for me to tell what
exactly might fail during runtime since neither __DLLstart() nor main()
are defined.

I consider this exercise concluded.

// File: bar.c
#include <stdio.h>

#include "foo.h"

int main( int argc, char *argv[] )
{
printf( "Hello, %s\n", foo() );

return 0;
}

// End: bar.c

## File: Makefile

bar.exe: bar.obj foo.dll
wlink system 386 name bar file bar import foo_ foo

bar.obj: bar.c
wcc386 -6r bar.c

foo.dll: foo.obj
wlink system 386 dll option map,undefsok name foo file foo

foo.obj: foo.c
wcc386 -bd -6r foo.c

## End: Makefile
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Paul S. Person
2018-01-02 17:53:57 UTC
Permalink
On Tue, 2 Jan 2018 07:16:17 +0800, Johann 'Myrkraverk' Oskarsson
Post by Johann 'Myrkraverk' Oskarsson
See the Linker Guide, The OS/2 Executable and DLL File Formats, of
all places.
I'm looking at it.

It says:

CauseWay DOS extender, Tenberry Software's DOS/4G and DOS/4GW DOS
extenders, and compatible products (LE format only)

under

The OS/2 32-bit linear executable file format will run under the
following operating systems.

I suggest that, although a DLL is an executable file rather than a
library, the actual meaning is that EXE files will do this (provided
the linker is given the right information).
--
"Nature must be explained in
her own terms through
the experience of our senses."
Continue reading on narkive:
Loading...