OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Dave Yeo on December 07, 2016, 04:55:28 pm
-
I'm trying to link a GCC built DLL to an OpenWatcom binary and it is failing with unresolved symbols.
Seems it is using the wrong calling convention, the OW binary is expecting foo_ instead of the _foo symbol that is exported.
Anyone know the correct OW CFLAGS to produce the correct calling convention, STDCALL IIRC?
-
Hi Dave,
I'm trying to link a GCC built DLL to an OpenWatcom binary and it is failing with unresolved symbols.
Seems it is using the wrong calling convention, the OW binary is expecting foo_ instead of the _foo symbol that is exported.
Anyone know the correct OW CFLAGS to produce the correct calling convention, STDCALL IIRC?
You might need to rebuild the GCC dll with _System declaration around the functions you want to use within OW....
Cheers,
Paul
-
2Dave Yeo: You need to specify the correct GCC function prototype in Watcom source header, with correct calling convention. GCC is mostly using __cdecl and Watcom expects __watcall by default. So, you need to specify __cdecl explicitly in prototypes.
-
A number of years ago I had to use the IBM C++ compiler to access old Microsoft OS/2 C DLLs. The way it had to be done was to load the DLL into memory directly and use a far call to directly call the functions. Somewhere I have the code if needed. The technique works fine. You just need to make sure and remove the DLLs manually after use or you end up with a memory leak.
-
I was linking to Cairo and used this patch to make it work,
--- cairo.h.orig 2016-06-19 22:41:04.000000000 -0700
+++ cairo.h 2016-12-22 23:22:34.000000000 -0800
@@ -53,9 +53,11 @@
#ifndef cairo_public
# if defined (_MSC_VER) && ! defined (CAIRO_WIN32_STATIC_BUILD)
# define cairo_public __declspec(dllimport)
+# elif defined (__WATCOMC__) && defined (__OS2__)
+# define cairo_public __declspec(__cdecl)
# else
# define cairo_public
# endif
#endif
CAIRO_BEGIN_DECLS
And of course create an OMF import lib