I tried several times to build wxMSW 2.8.10 (wxWidgets) with Open
Watcom 1.8. I always got the following error when I tried to start the
minimal sample application:
The application could not initialized properly (0xc0000005).
I have tested this scenario now with a nearly fresh test setup and
have build wxMSW in release / DLL mode.
I got the same error when I have compiled my application on Windows
2000 and on Windows XP with latest updates.
The library compiled successfully with buildwxWidgets.bat as shown
below.
And wxWidgets was installed at C:\lbDMF\Develop\wxwin\wx.
I do not know what the problem is, but since I updated to OW 1.8 I
have these problems.
Does anyone have similar problems?
I could provide a installation file for this environment if someone
needs it (or even a zip file of the install).
Thanks
Lothar
The batchfile that starts my wxMSW build is as follows
(buildwxWidgets.bat):
@rem This batch will build the wxWidgets library after the
installation.
echo dummy > readme.txt
call watcomenv.bat exit
echo del readme.txt > doBuildWx.bat
echo set DRIVE=%DEVLW% >> doBuildWx.bat
echo set WXDIR=%DRIVE%\lbDMF\Develop\wxwin\wx >> doBuildWx.bat
echo %DRIVE% >> doBuildWx.bat
echo cd %WXDIR%\build\msw >> doBuildWx.bat
echo copy /Y %WXDIR%\include\wx\msw\setup.h %WXDIR%\include\wx >>
doBuildWx.bat
rem echo wmake -f makefile.wat clean >> doBuildWx.bat
rem echo @pause Build starten? >> doBuildWx.bat
echo wmake -f makefile.wat all >> doBuildWx.bat
call watcomenv.bat doBuildWx.bat
****************************************************************************************************
Compiling the minimal sample was performed as follows:
C:\lbDMF\Develop\wxwin\wx\samples\minimal>wmake -f makefile.wat
Open Watcom Make Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
if not exist wat_mswdll mkdir wat_mswdll
mkdir wat_mswdll
wpp386 -bt=nt -zq -fo=wat_mswdll\minimal_minimal.obj -d0 -ot -
ox -bm -br
-d__WXMSW__ -i=.\..\..\lib\wat_dll\msw -i=.\..\..\include -wx -
wcd=549 -
wcd=656 -wcd=657 -wcd=667 -i=. -dWXUSINGDLL -i=.\..\..\samples -dNOPCH
-xr -xs
.\minimal.cpp
wrc -q -ad -bt=nt -r -fo=wat_mswdll\minimal_sample.res -
d__WXMSW__
-i=.\..\..\lib\wat_dll\msw -i=.\..\..\include -i=. -dWXUSINGDLL -
i=.\..\..
\samples -dNOPCH .\..\..\samples\sample.rc
wlink @wat_mswdll\minimal.lbc
****************************************************************************************************
and the watcomenv.bat is as follows:
if EXIST readme.txt goto WEITER:
set DEVLW=%%DEVLW%%
set DEVROOT=%%DEVROOT%%
echo
------------------------------------------------------------------------
>> readme.txt
echo * Basic development
settings * >> readme.txt
echo
------------------------------------------------------------------------
>> readme.txt
echo * You have started lbDMF Develop the first time. Please
read * >> readme.txt
echo * lbDMF Help at your desktop for further
instructions. * >> readme.txt
echo
*
* >> readme.txt
echo * If you don't find the help icon, download the
latest * >> readme.txt
echo * documentation install package from my sourceforge project
site. * >> readme.txt
echo
------------------------------------------------------------------------
>> readme.txt
start notepad readme.txt
exit
:WEITER
rem set TARGET_APPLICATION=Application
set CONSOLE_DETACH=yes
rem set lbDMFPasswd=
rem set lbDMFUser=
if NOT "%COMPUTERNAME%"=="ANAKIN" goto DISTMODE:
set DEVLW=q:
set BASE=develop
set BASE_MAKE=develop
set DEVROOT=%DEVLW%\%BASE%
set DEVROOT_MAKE=%DEVLW%/%BASE_MAKE%
goto BEGINENVIRONMENT:
:DISTMODE
if "%2"=="CC" goto CCBUILD:
set DEVLW=C:
set BASE=lbDMF\develop
set BASE_MAKE=lbDMF/develop
set DEVROOT=%DEVLW%\%BASE%
set DEVROOT_MAKE=%DEVLW%/%BASE_MAKE%
goto BEGINENVIRONMENT:
:CCBUILD
set DEVLW=E:
set BASE=Programme\CruiseControl\projects\lbDMF\develop
set BASE_MAKE=Programme/CruiseControl/projects/lbDMF/develop
set DEVROOT=%DEVLW%\%BASE%
set DEVROOT_MAKE=%DEVLW%/%BASE_MAKE%
:BEGINENVIRONMENT
@rem ----------------------------------------------------------------
@rem * End config *
@rem ----------------------------------------------------------------
rem WXWIN stuff
set WXWIN=%DEVLW%\%BASE%\wxwin\wx
set WXDIR=%WXWIN%
set PLUGIN_DIR=%DEVLW%\%BASE%\Projects\plugins
set MSVCDir=%DEVLW%\%BASE%\Tools\MSC\VC98
@rem Alias to the linux environment
set OSTYPE=%OS%
rem Basic Runtime settings
set RUNROOT=%DEVLW%\%BASE%\projects
rem Some bin dirs for development
rem set CVSBIN=%DEVROOT%\Tools\cvs
set WATBIN=%DEVLW%\%BASE%\Tools\WATCOM\BINNT;%DEVROOT%\Tools\WATCOM
\BINW
set DEVBIN=%DEVLW%\%BASE%\bin
rem Some dll and bin search Paths
set DLLROOT=%RUNROOT%\dll
set BINROOT=%RUNROOT%\bin;%RUNROOT%\CPP\bin
set Path=%DEVLW%\%BASE%\bin;%SystemRoot%\system32;%DEVLW%\;%WATBIN%;
%DEVBIN%;%DLLROOT%;%BINROOT%
set Path=%Path%;q:\develop\tools\cygwin\bin;Q:\develop\Tools\Perl
\bin;G:\gs\gs8.15\bin
set Path=%Path%;Q:\develop\Tools\TP;Q:\develop\Tools\TP\TPU
set Path=%path%;G:\FPC\2.0.4\bin\i386-win32
rem Enable my Power++ IDE
set Path=%Path%;"E:\Program Files\Powersoft\Power21\System"
set Path=%Path%;Q:\develop\Tools\Bakefile\src
set MSC=%MSVCDir%\Bin;%MSVCDir%\Lib
set Path=%MSC%;%Path%;%DEVLW%\%BASE%\bin
rem ??? F:\develop\NT\DevTools\bin
rem MSC Library path
set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%
rem Watcom stuff
SET INCLUDE=%DEVLW%\%BASE%\wxwin\wx\src\msw;%DEVLW%\%BASE%\Tools\WATCOM
\;%DEVLW%\%BASE%\Tools\WATCOM\h;%DEVLW%\%BASE%\Tools\WATCOM\h\nt
rem SET INCLUDE=%INCLUDE%;"C:\Program Files\Microsoft Visual Studio
\VC98\MFC\Include";%MSVCDir%\Include
rem ???;D:\Develop\Tools\WATCOM\H\NT
rem SET INCLUDE=
SET WATCOM=%DEVLW%\%BASE%\Tools\WATCOM
SET EDPath=%DEVLW%\%BASE%\Tools\WATCOM\EDDAT
@rem XML Module Configuration
set LBHOSTCFGFILE=%DEVLW%\%BASE%\Projects\CPP\Test\Console\XML
\lbXMLConfig.xml
REM __stdcall convention
set LBXMLFUNCTOR=_getlbDOMConfigInstance@16
REM __cdecl convention
REM set LBXMLFUNCTOR=getlbDOMConfigInstance
set LBXMLLIB=lbDOMConfig
@rem lbModule configuration
set MODULELIB=lbModule
REM __stdcall convention
REM set LBMODULEFUNCTOR=_getlb_ModuleInstance@4
REM __cdecl convention
set LBMODULEFUNCTOR=getlb_ModuleInstance
REM ------------------------------------------------------------
REM This stuff is added due to integrate Doxygen into my console
REM ------------------------------------------------------------
set BISON_SIMPLE=%DEVROOT_MAKE%/projects/bin/bison.simple
set path=%path%;%DEVLW%\develop\Tools\Perl\bin\
REM -------------------
REM Prepend my cvs path
REM -------------------
set path=C:\Program Files\GNU\WinCvs 1.2;%PATH%
if "%2"=="CC" goto CCBUILD_END:
rem set CONSOLE_DETACH=no
rem wdw ..\..\bin\%1
start %1
:CCBUILD_END
Lothar
chris elliott schrieb:
Lothar Behrens wrote:
> As reported I have tested also on XP SP3 I think. The update some days
> ago.
> Currently I download the 1.9 test version. Then I'll try 1.7 if the
> code will compile with
> that version.
>
> Lothar
I don't think it will work with 1.7
chris
I now have tested 1.9 and it reports the same error (on my Win 2000
box). Also strange is the linking of DLL's. It tries to load
wxmsw28_wat_custom without the
dll extension. But may be due to the daily build version.
Currently I skip 1.7.
Lothar
It is likely access violation exception (probably some command made
access incorrect memory address).
I have assumption that problem may be because some global or static
variable initialization works bad when some address used as initializer
and this address is inside dll (an address of address then is used
instead). Because of this Open Watcom bug, for example, some function
(which may be some initialization function) may not be called if a call
is through variable, which is initialized to an address of this
function, but access violation exception occurs. This bug is frequent
causes problems with dlls. In particular, building Open Watcom tools
with linking with dll runtime libraries ends failed :-/
I think you have to debug your application and library and made some
corrections or you have address a problems to library author(s), if they
supports the use of library as you need. Or you have wait. Or use
another library... :-)
#include <stdio.h>
int (*pf)(const char *)=&puts;
int main()
{
pf("hello, world");
return 0;
}
If this is compiled against dll runtime C library (with -br compiler
switch) by C compiler, then resulting executable will crash. With C++
compiler (and with -br switch) all works right and outputs to console
"hello, world".
Are you writing that the code above compiles as C++ without the usual
extern "C" {} wrapper?
This is with svn:
Last Changed Rev: 60297
Last Changed Date: 2009-04-24 06:06:25 +0100 (Fri, 24 Apr 2009)
I did modify the local makefile.wat to remove the ifdef __LOADDLL__ section:
K:\wx\wxw28b\samples\minimal>svn diff
Index: makefile.wat
===================================================================
--- makefile.wat (revision 60319)
+++ makefile.wat (working copy)
@@ -11,17 +11,8 @@
#
-------------------------------------------------------------------------
# Speed up compilation a bit:
-!ifdef __LOADDLL__
-! loaddll wcc wccd
-! loaddll wccaxp wccdaxp
-! loaddll wcc386 wccd386
-! loaddll wpp wppdi86
-! loaddll wppaxp wppdaxp
-! loaddll wpp386 wppd386
-! loaddll wlink wlink
-! loaddll wlib wlibd
-!endif
+
# We need these variables in some bakefile-made rules:
WATCOM_CWD = $+ $(%cdrive):$(%cwd) $-
Sorry about the line wrap, but this is my compile and run
K:\wx\wxw28b\samples\minimal>wmake -f makefile.wat
Open Watcom Make Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
wpp386 -bt=nt -zq -fo=wat_mswd\minimal_minimal.obj -d2 -od -bm
-br -d__W
XMSW__ -d__WXDEBUG__ -i=.\..\..\lib\wat_lib\mswd
-i=.\..\..\include -wx -
wcd=549 -wcd=656 -wcd=657 -wcd=667 -i=. -i=.\..\..\samples -dNOPCH -xr
-xs .\
minimal.cpp
wrc -q -ad -bt=nt -r -fo=wat_mswd\minimal_sample.res
-d__WXMSW__ -d_
_WXDEBUG__ -i=.\..\..\lib\wat_lib\mswd -i=.\..\..\include -i=.
-i=.\..\.
.\samples -dNOPCH .\..\..\samples\sample.rc
wlink @wat_mswd\minimal.lbc
K:\wx\wxw28b\samples\minimal>cd wat_mswd
K:\wx\wxw28b\samples\minimal\wat_mswd>minimal.exe
K:\wx\wxw28b\samples\minimal\wat_mswd>
chris
:-) Yes. I test it. (with Open Watcom 1.8 on Windows).
In general pointer pf may be necessary declare with extern "C" (as puts
is extern "C", in Open Watcom header files it is).
Real problem (with such call function by pointer) might occurs if there
is differences in calling conventions (__cdecl, __stdcall etc). It may
occurs if functions is declared wrong...
Please, can you give some real code example for absence __watcall.
Jiri
See above.
The first problem is linker problem, for variable with function addres (indirection) for function
imported from DLL.
Linker should generate small redirection code shunk but doesn't create it for this issue.
Second one is related to too restrictive C++ compiler diagnostic for function pointers, generated
code is OK.
Compiler differs between function pointer without explicitly defined calling convention(implicit)
and
explicitly defined convention even if they are same, similar problem occure if you use -ec...
option.
Jiri
What about linker, there is no problem.
I test the following example with C compiler.
__declspec(__watcall) int puts(const char *);
int (* pf)(const char *)=&puts;
int main()
{
pf("hello, world");
return 0;
}
It works OK. I have carefully checked up and it really calls puts from
dll (through some jmp instruction).
I have nothing against the warning from C++ compiler in this case. I
simple have explained what is the reason of the warning, because this it
not obviously clear (extern "C" is in discussion) :-)
Thank you :-)
And I found that C++ compiler generates special code for run-time
initialization of such (dll imported) pointers to function. And when
there is some another initializers, which has been written in the
assumption that such pointers is initialized (before program start), a
crash again may occurs :-(
could you send me a patch file against the official wxMSW 2.8.10
release?
Also: Do you send the patch to wxWidgets developers, or needs this to
be tested once more?
Thanks
Lothar
And even if linker would have a problems (really, not have), a linking
error is preferred than unpredictable behavior or crash at runtime...
Please let me know here of any problems
chris