Discussion:
Watcom and dlls
(too old to reply)
Jens Staal
2014-10-01 03:34:22 UTC
Permalink
Hi

One thing I am trying to do at the moment (slowly because RL stuff takes
much time) is to package several "core" libraries for OpenWatcom
(cross-)compilation on Arch linux (for starters, targets are linux, dos 16-
and 32-bit, win32).

As a first practice package, I choose zlib since it is a small and nicely
behaving source.

The dos targets already had wmake files so those were easy
linux and win32 static libraries built nicely too

For win32, I used "owcc" and modified the GNU makefile (Makefile.gcc) under
the win32 directory. wrc could handle the zlib1.rc for the static library.
For the dynamic library however I also need to somehow make use of the
"zlib.def" definition file (the same file is used for both mingw and msvc
builds). The Watcom wiki just quickly mentions definition files in its dll
section without saying how those are used.

some pointers would be appreciated ;) (or if there are more general tips-
and-tricks regarding building dlls I am also interested in those)

PS. Is there any corresponding "owcc" for wpp/wpp386? Right now I can
substitute "gcc" for "owcc" but how should I substitute "g++"? Ds.
Hans-Bernhard Bröker
2014-10-01 18:41:04 UTC
Permalink
Post by Jens Staal
PS. Is there any corresponding "owcc" for wpp/wpp386?
Yes. owcc is it.
Dave Yeo
2014-10-02 02:59:16 UTC
Permalink
Post by Jens Staal
For the dynamic library however I also need to somehow make use of the
"zlib.def" definition file (the same file is used for both mingw and msvc
builds). The Watcom wiki just quickly mentions definition files in its dll
section without saying how those are used.
Usually def files are added to the linker line along with the object
files though I haven't used one with OW
Dave
news.openwatcom.org
2014-10-02 05:58:09 UTC
Permalink
OW wlink doesn't use *.def file, it uses "EXPORT" directive.
You need convert *.def file to appropriate "EXPORT" compatible form.
See details in WLINK documentation for EXPORT directive.

There is second possibility to expport symbols from DLL, but it requires
source code modification.
In this case you add __declspec( dllexport) to each exported function and
you don't need any *.def file, because info about symbol export is included
into object file.

Equivalent for "g++" is "owcc -xc++" and "gcc" is "owcc -xc" (only for C
source).
Simple "owcc" use autodetection by source file name extension
following is C++ extension ".cp",".cpp",".cxx",".cc",".hpp",".hxx" and for
unix hosts also ".c++",".C"
all others are C extensions.

Export directive for wlink you can pass by -Wl option.
More details you can find in owcc and wlink documentation.

Jiri
Post by Jens Staal
For the dynamic library however I also need to somehow make use of the
"zlib.def" definition file (the same file is used for both mingw and msvc
builds). The Watcom wiki just quickly mentions definition files in its dll
section without saying how those are used.
some pointers would be appreciated ;) (or if there are more general tips-
and-tricks regarding building dlls I am also interested in those)
PS. Is there any corresponding "owcc" for wpp/wpp386? Right now I can
substitute "gcc" for "owcc" but how should I substitute "g++"? Ds.
Jens Staal
2014-10-03 11:21:17 UTC
Permalink
Post by news.openwatcom.org
Equivalent for "g++" is "owcc -xc++" and "gcc" is "owcc -xc" (only for C
source).
Simple "owcc" use autodetection by source file name extension
following is C++ extension ".cp",".cpp",".cxx",".cc",".hpp",".hxx" and for
unix hosts also ".c++",".C"
That is very cool :) I was going to package some source-to-source compilers
(like p2c and "portable object compiler") to point to watcom (for easy
cross-compilation).
Pointing to owcc will then handle all use cases (C / C++) (16 / 32 -bit).
Jens Staal
2014-10-03 11:39:21 UTC
Permalink
This post might be inappropriate. Click to display it.
Jiri Malak
2014-10-03 18:18:45 UTC
Permalink
It is similar problem as exported symbols, there is again two possibilty.

First one to is to use wlink directive library to specify list of libraries
for linking.
second one is use information in source code, for OW compilers it is #pragma
library. In this case library information is build into object file.

Jiri
Post by Jens Staal
Post by news.openwatcom.org
OW wlink doesn't use *.def file, it uses "EXPORT" directive.
You need convert *.def file to appropriate "EXPORT" compatible form.
See details in WLINK documentation for EXPORT directive.
Thanks I will try to read up on this. Hopefully I can build dlls without
extensive source code modifications (which makes the packaging more
involved). Otherwise I will just remain happy with static libs.
A packaging question: dlls go into $WATCOM/binnt and not in
$WATCOM/lib386/nt/ ?
Do one explicitly need to add a
#pragma library ('xxx.lib')
to the headers to make the compiler know which library to link?
Hans-Bernhard Bröker
2014-10-03 18:46:12 UTC
Permalink
Post by Jens Staal
A packaging question: dlls go into $WATCOM/binnt and not in
$WATCOM/lib386/nt/ ?
Neither. DLLs which you build yourself should not be dumped into OW's
own directory tree.
Jiri Malak
2014-10-04 07:34:32 UTC
Permalink
It is run-time DLLs and they must be visible for OS on run-time.
Location depend on host OS.
For 16/32/64-bit Windows they are in standard binary directories
$WATCOM/biw, $WATCOM/binnt, $WATCOM/binnt64.
For OS/2 it is in $WATCOM/binp/dll.
Appropriate import libraries (*.lib) are located in appropriate subdirectory
for standard libraries (static).
Reference to run-time DLL import libraries are included automaticaly by
compiler. Unfortunately this feature can be switch off.
Post by Jens Staal
A packaging question: dlls go into $WATCOM/binnt and not in
$WATCOM/lib386/nt/ ?
Do one explicitly need to add a
#pragma library ('xxx.lib')
to the headers to make the compiler know which library to link?
Lynn McGuire
2014-10-02 20:01:22 UTC
Permalink
Post by Jens Staal
Hi
One thing I am trying to do at the moment (slowly because RL stuff takes
much time) is to package several "core" libraries for OpenWatcom
(cross-)compilation on Arch linux (for starters, targets are linux, dos 16-
and 32-bit, win32).
As a first practice package, I choose zlib since it is a small and nicely
behaving source.
The dos targets already had wmake files so those were easy
linux and win32 static libraries built nicely too
For win32, I used "owcc" and modified the GNU makefile (Makefile.gcc) under
the win32 directory. wrc could handle the zlib1.rc for the static library.
For the dynamic library however I also need to somehow make use of the
"zlib.def" definition file (the same file is used for both mingw and msvc
builds). The Watcom wiki just quickly mentions definition files in its dll
section without saying how those are used.
some pointers would be appreciated ;) (or if there are more general tips-
and-tricks regarding building dlls I am also interested in those)
PS. Is there any corresponding "owcc" for wpp/wpp386? Right now I can
substitute "gcc" for "owcc" but how should I substitute "g++"? Ds.
To build a Win32 DLL, I use wlink and a *.lnk file:

link.bat:

del something.dll
wlink @something.lnk
del something.lib
rem create a Visual C++ import library, something.lib
wlib something +something.dll

something.lnk:

system nt_dll
name something.dll
option map
option stack=1000k
debug all
export MY_FANCY_ENTRY_POINT
...
file something.obj
...
# for SHGetFolderPath
library %watcom%\lib386\nt\shfolder.lib


Lynn
Jens Staal
2014-10-03 11:47:29 UTC
Permalink
Post by Lynn McGuire
del something.dll
del something.lib
rem create a Visual C++ import library, something.lib
wlib something +something.dll
system nt_dll
name something.dll
option map
option stack=1000k
debug all
export MY_FANCY_ENTRY_POINT
...
file something.obj
...
#for SHGetFolderPath
library %watcom%\lib386\nt\shfolder.lib
This looks very interesting and less invasive than source code changes
adding __declspec(dllexport) to every exported function.
I will read the definition file and try to figure out how involved the two
different approaches may be.
Continue reading on narkive:
Loading...