PRB: L2029 '_exit' Unresolved External from STOP Stmt in DLL
ID: Q102693
|
The information in this article applies to:
-
Microsoft FORTRAN for MS-DOS, version 5.1
SYMPTOMS
An attempt to link a dynamic-link library (DLL) for the Microsoft
Windows operating system fails and Microsoft LINK generates the
following message:
error L2029: '_exit' : unresolved external
CAUSE
Microsoft FORTRAN does not support using the STOP statement in a DLL
developed for Windows.
RESOLUTION
To terminate the DLL and the calling application, use the
SendMessage() function in the Windows application programming
interface (API) to send the calling application a WM_QUIT message. The
code example below demonstrates this technique.
MORE INFORMATION
The code example below terminates the DLL and the calling application
after displaying a message box warning the user to save all data.
Sample Code - EXIT.FOR
C Compiler options needed: /c /Od /Zi /AL
interface to integer*2 function PostAppMessage[pascal]
+ (htask, msg, wparam, lparam)
integer*2 htask[value]
integer*2 msg[value]
integer*2 wparam[value]
integer*4 lparam[value]
end
interface to integer*2 function GetCurrentTask[pascal]
end
interface to integer*2 function MessageBox[pascal]
+ (hwnd, boxtext, caption, boxtype)
integer*2 hwnd[value]
character*1 boxtext[reference]
character*1 caption[reference]
integer*2 boxtype[value]
end
subroutine exit
integer*2 in
character buffer1*120, buffer2*80
integer*2 i, WM_QUIT, PostAppMessage, GetCurrentTask, MessageBox
WM_QUIT = #12
buffer1 =
+'************** DLL issued STOP Statement ************'//
+'\n Application will terminate. Save contents of windows NOW'c
buffer2 = 'DLL STOP'c
i = MessageBox(0, buffer1, buffer2, 0)
i = PostAppMessage(GetCurrentTask(), WM_QUIT, in, 0)
return
end
The following QuickWin driver program calls the subroutine in
DLLTEST.FOR.
Sample Code - TEST.FOR
C Compiler options needed: /c /Od /Zi /MW
program testdllstop
print *, 'before calling DLL'
call dllsub
print *, 'back from sub1'
end
The following DLL displays a dialog box and calls the exit subroutine
to close the DLL and the calling application.
Sample Code - DLLTEST.FOR
C Compiler options needed: /c /Od /Zi /Aw /Gw
interface to integer*2 function MessageBox[pascal]
+ (hwnd, boxtext, caption, boxtype)
integer*2 hwnd[value]
character*1 boxtext[reference]
character*1 caption[reference]
integer*2 boxtype[value]
end
subroutine dllsub
integer*2 messagebox
i = MessageBox(int2(0), 'Prior to STOP statement in DLL'c,
+ ' 'c, 0)
call exit
end
DLLTEST.DEF
LIBRARY DLLTEST
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS DLLSUB
WEP
MAKEFILE
all: test.exe dlltest.dll
test.obj: test.for
fl /c /Od /Zi /MW test.for
dlltest.obj: dlltest.for
fl /c /Od /Zi /Aw /Gw dlltest.for
exit.obj: exit.for
fl /c /Od /Zi /AL exit.for
dlltest.dll: dlltest.obj exit.obj
link dlltest exit, dlltest.dll, nul, /co /nod ldllfew, dlltest.def;
dlltest.lib: dlltest.def
implib dlltest.lib dlltest.def
test.exe: test.obj dlltest.lib
link test, test, nul, /co /nod llibfew dlltest,
c:\fortran\binb\fl.def;
Additional query words:
5.10
Keywords :
Version : :5.1
Platform :
Issue type :