[comp.os.os2.programmer] Multithreaded DLLs

d85-caj@dront.nada.kth.se (Catrin Johnson) (03/06/91)

I am using IBM os/2 ver 1.2 and have to develop an application in IBM
Pascal/2.This application has to use a DLL that I created earlier
using Microsoft C (ver 5.1).This is a multithreaded DLL which uses the
C runtime library CRTLIB.DLL, provided with the compiler. When a C
application uses my DLL it has to be linked with crtexe.obj, which I
assume performs some initialization. I have not been able to make the
Pascal application make use of this DLL, and in fact I have hardly
been able to make it interact with the operating system at all. So, my
questions are the following:

1: Doscalls are declared in a file called doscalls.int. In my case
this file is pretty old, and was created for os/2 ver 1.0, which may
be a problem. I have only tried a few doscalls, but they are seldom
successful. DosCreateThread returns 164, which is an error code
unknown to me. DosSemSetWait crashes the system, I do not remember the
error code. DosAllocSeg seems to be successful, but I do not know how
to handle the word type address received when sending it to
DosCreateThread, which asks for an integer4 type address.

Anyone out there who has succesfully used the doscalls from Pascal??

2: How do I link an object module created by the Pascal compiler with
an object module created by the C compiler if they both need their
runtime libraries? I get a number of multiply defined symbols.

3: Is it possible for a Pascal application to use a DLL which uses
CRTLIB.DLL, and if so, how?

4: Does anyone know how to make the otherwise excellent debugger
MultiScope understand that there are variables declared in a Pascal
program? It informs me that there is no global or local data, no
matter how many variables I declare.


Please answer by email to:
d85-caj@nada.kth.se

and please do so even if you only know the answer to one or a few questions.

Regards
Catrin
 

towfiq@FTP.COM (Mark Towfiq) (03/13/91)

In article <1991Mar5.203638.28038@nada.kth.se>
d85-caj@dront.nada.kth.se (Catrin Johnson) writes:

   I am using IBM os/2 ver 1.2 and have to develop an application in IBM
   Pascal/2.This application has to use a DLL that I created earlier
   using Microsoft C (ver 5.1).This is a multithreaded DLL which uses the
		      ^^^|^^^
		A problem in itself...

   C runtime library CRTLIB.DLL, provided with the compiler. When a C
   application uses my DLL it has to be linked with crtexe.obj, which I
   assume performs some initialization. I have not been able to make the
   Pascal application make use of this DLL, and in fact I have hardly
   been able to make it interact with the operating system at all. So, my
   questions are the following:

   1: Doscalls are declared in a file called doscalls.int. In my case
   this file is pretty old, and was created for os/2 ver 1.0, which may
   be a problem.

I have never heard of this file.  Do you mean doscalls.lib?  (Now
replaced by os2.lib).

   I have only tried a few doscalls, but they are seldom successful.

Between MS C 5.1 and doscalls.INT, I can believe that.

   DosCreateThread returns 164, which is an error code unknown to me.

That means "maximum threads reached" -- look in bseerr.h.

   DosSemSetWait crashes the system, I do not remember the
   error code. DosAllocSeg seems to be successful, but I do not know how
   to handle the word type address received when sending it to
   DosCreateThread, which asks for an integer4 type address.

   Anyone out there who has succesfully used the doscalls from Pascal??

   2: How do I link an object module created by the Pascal compiler with
   an object module created by the C compiler if they both need their
   runtime libraries?

You probably don't...

   I get a number of multiply defined symbols.

What symbols?

   3: Is it possible for a Pascal application to use a DLL which uses
   CRTLIB.DLL, and if so, how?

I am not sure (having never used Pascal/2), but I am pretty sure you
must link in crtexe.obj and have a function called main().

   4: Does anyone know how to make the otherwise excellent debugger
   MultiScope understand that there are variables declared in a Pascal
   program? It informs me that there is no global or local data, no
   matter how many variables I declare.

Sounds like you are using the wrong linker.  MultiScope folks say they
don't support the symbol format generated by the latest version of the
linker, I'm told (5.10?).  You could risk using an older linker.

One big problem you could be having is not using the "latest &
greatest" include files, libs, compilers, linkers, and DLLs.  I would
check carefully the status of each of these parts, as they can be the
source of great woe.  Do you have the PMSDK installed, for example?
The header files and libs there are different from MS C 5.1 (which I
would immediately upgrade to C 6.0, if I were you).

Hope this helps...
--
Mark Towfiq, FTP Software, Inc.                                  towfiq@FTP.COM
Work No.: +1 617 246 0900			      Home No.: +1 617 488 2818

  "The Earth is but One Country, and Mankind its Citizens" -- Baha'u'llah