build wxPython 2.8

Hello,

Can I build Wxwidgets using Visual Studio 2008? Directly click \build
\msw\wx_dll.dsw after modifying the setup.h.

In this case, how to set up the options specified for nmake in Visual
Studio 2008?

for example: CXXFLAGS=/D__NO_VC_CRTDBG__ WXDEBUGFLAG=h
                   MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1

Thank you.

Yes, it's possible. You'll want to watch what compile/link command lines are used from nmake in response to the flags above (or examine the makefile) and then set the same compile/link flags in the MS Studio project configurations.

···

On 12/27/10 1:37 PM, wofeib wrote:

Hello,

Can I build Wxwidgets using Visual Studio 2008? Directly click \build
\msw\wx_dll.dsw after modifying the setup.h.

In this case, how to set up the options specified for nmake in Visual
Studio 2008?

for example: CXXFLAGS=/D__NO_VC_CRTDBG__ WXDEBUGFLAG=h
                    MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1

--
Robin Dunn
Software Craftsman

I'm following the procedure here: http://www.wxpython.org/BUILD-2.8.html
to build wxpython 2.8.11 and got the problem.
( source is downloaded from here: http://www.wxpython.org/download.php
)

nmake.exe -f makefile.vc UNICODE=1 MSLU=1 OFFICIAL_BUILD=1 SHARED=1
MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1 CXXFLAGS=/D__NO_VC_CRTDBG__
DEBUG_FLAG=1 WXDEBUGFLAG=h BUILD=release

wxwidgetes is build successfully.

However, when I build wxpython:

python setup.py build_ext --inplace MONOLITHIC=0 UNICODE=1

the error shows below: (same as this post:
http://osdir.com/ml/python.wxpython.devel/2008-06/msg00046.html)

Thank you for help.

···

======================================================================

building '_core_' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /
Ox /MD /W
3 /GS- /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -
DSWIG_TYPE_TABLE=
_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -
DISOLATION_AWARE_
ENABLED -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -
Iinclude -I
src -ID:\wxPython-src-2.8.11.0\lib\vc_dll\mswuh -ID:\wxPython-
src-2.8.11.0\inclu
de -ID:\wxPython-src-2.8.11.0\contrib\include -IC:\Python26\include -
IC:\Python2
6\PC /Tpsrc/helpers.cpp /Fobuild.unicode\temp.win32-2.6\Release\src/
helpers.obj
/Gy /EHsc
cl : Command line warning D9025 : overriding '/DNDEBUG' with '/
UNDEBUG'
helpers.cpp
D:\wxPython-src-2.8.11.0\include\wx/msw/wrapwin.h(89) : warning C4005:
'GetOpenF
ileNameW' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include
\commdlg.inl(988) :
see previous definition of 'GetOpenFileNameW'
D:\wxPython-src-2.8.11.0\include\wx/msw/wrapwin.h(92) : warning C4005:
'GetSaveF
ileNameW' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include
\commdlg.inl(990) :
see previous definition of 'GetSaveFileNameW'
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\rc.exe -DWIN32 -
D_WINDOWS -D__
WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -
DSWIG_PYTHON_OUTPUT_TU
PLE -DWXP_USE_THREAD=1 -DISOLATION_AWARE_ENABLED -UNDEBUG -
D__NO_VC_CRTDBG__ -D_
_WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -ID:\wxPython-
src-2.8.11.0\lib\vc_d
ll\mswuh -ID:\wxPython-src-2.8.11.0\include -ID:\wxPython-
src-2.8.11.0\contrib\i
nclude -IC:\Python26\include -IC:\Python26\PC /fobuild.unicode
\temp.win32-2.6\Re
lease\src/wxc.res src/wxc.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /
Ox /MD /W
3 /GS- /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -
DSWIG_TYPE_TABLE=
_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -
DISOLATION_AWARE_
ENABLED -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -
Iinclude -I
src -ID:\wxPython-src-2.8.11.0\lib\vc_dll\mswuh -ID:\wxPython-
src-2.8.11.0\inclu
de -ID:\wxPython-src-2.8.11.0\contrib\include -IC:\Python26\include -
IC:\Python2
6\PC /Tpsrc\msw\_core_wrap.cpp /Fobuild.unicode\temp.win32-2.6\Release
\src\msw\_
core_wrap.obj /Gy /EHsc
cl : Command line warning D9025 : overriding '/DNDEBUG' with '/
UNDEBUG'
_core_wrap.cpp
D:\wxPython-src-2.8.11.0\include\wx/msw/wrapwin.h(89) : warning C4005:
'GetOpenF
ileNameW' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include
\commdlg.inl(988) :
see previous definition of 'GetOpenFileNameW'
D:\wxPython-src-2.8.11.0\include\wx/msw/wrapwin.h(92) : warning C4005:
'GetSaveF
ileNameW' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include
\commdlg.inl(990) :
see previous definition of 'GetSaveFileNameW'
src\msw\_core_wrap.cpp(4621) : warning C4996: 'wxSizer::Remove': was
declared de
precated
        D:\wxPython-src-2.8.11.0\include\wx/sizer.h(513) : see
declaration of 'w
xSizer::Remove'
src\msw\_core_wrap.cpp(4621) : warning C4996: 'wxSizer::Remove': was
declared de
precated
        D:\wxPython-src-2.8.11.0\include\wx/sizer.h(513) : see
declaration of 'w
xSizer::Remove'
src\msw\_core_wrap.cpp(33938) : warning C4996: 'wxGetAccelFromString':
was decla
red deprecated
        D:\wxPython-src-2.8.11.0\include\wx/utils.h(579) : see
declaration of 'w
xGetAccelFromString'
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /
nologo /INCRE
MENTAL:NO /LIBPATH:D:\wxPython-src-2.8.11.0\lib\vc_dll /LIBPATH:C:
\Python26\libs
/LIBPATH:C:\Python26\PCbuild wxbase28uh.lib wxbase28uh_net.lib
wxbase28uh_xml.l
ib wxmsw28uh_core.lib wxmsw28uh_adv.lib wxmsw28uh_html.lib
kernel32.lib user32.l
ib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib
oldnames.lib comctl
32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib
advapi32.lib wsock3
2.lib /EXPORT:init_core_ build.unicode\temp.win32-2.6\Release\src/
helpers.obj bu
ild.unicode\temp.win32-2.6\Release\src/wxc.res build.unicode
\temp.win32-2.6\Rele
ase\src\msw\_core_wrap.obj /OUT:D:\wxPython-src-2.8.11.0\wxPython\wx
\_core_.pyd
/IMPLIB:build.unicode\temp.win32-2.6\Release\src\_core_.lib /
MANIFESTFILE:build.
unicode\temp.win32-2.6\Release\src\_core_.pyd.manifest
   Creating library build.unicode\temp.win32-2.6\Release\src
\_core_.lib and obje
ct build.unicode\temp.win32-2.6\Release\src\_core_.exp
helpers.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) v
oid __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const
*,wchar_t
const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z) referenced in function
"public: v
oid __thiscall wxMemoryBuffer::SetDataLen(unsigned int)" (?
SetDataLen@wxMemoryBu
ffer@@QAEXI@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport
) void __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t
const *,wchar
_t const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z)
helpers.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) v
oid __cdecl wxLogDebug(wchar_t const *,...)" (__imp_?
wxLogDebug@@YAXPB_WZZ) refe
renced in function "unsigned long __cdecl
wxPySetActivationContext(void)" (?wxPy
SetActivationContext@@YAKXZ)
helpers.obj : error LNK2001: unresolved external symbol "public:
virtual void __
thiscall wxAppConsole::OnAssert(wchar_t const *,int,wchar_t const
*,wchar_t cons
t *)" (?OnAssert@wxAppConsole@@UAEXPB_WH00@Z)
helpers.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) p
ublic: virtual void __thiscall wxAppConsole::OnAssertFailure(wchar_t
const *,int
,wchar_t const *,wchar_t const *,wchar_t const *)" (__imp_?
OnAssertFailure@wxApp
Console@@UAEXPB_WH000@Z) referenced in function "public: virtual void
__thiscall
wxPyApp::OnAssertFailure(wchar_t const *,int,wchar_t const *,wchar_t
const *,wc
har_t const *)" (?OnAssertFailure@wxPyApp@@UAEXPB_WH000@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport
) int g_isPainting" (__imp_?g_isPainting@@3HA) referenced in function
__wrap_new
_PaintEvent
D:\wxPython-src-2.8.11.0\wxPython\wx\_core_.pyd : fatal error LNK1120:
5 unresol
ved externals
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\link.exe"'
failed with exit status 1120

BTW, after running: nmake.exe -f makefile.vc UNICODE=1 MSLU=1
OFFICIAL_BUILD=1 SHARED=1
MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1 CXXFLAGS=/D__NO_VC_CRTDBG__
DEBUG_FLAG=1 WXDEBUGFLAG=h BUILD=release

Here is some output, looks like no wxdebug defined. is that the
reason? thank you.

        cl /EP /nologo "..\..\include\wx\msw\genrcdefs.h" > "..\..\lib
\vc_dll\ms
wuh\wx\msw\rcdefs.h"
genrcdefs.h
        cl /c /nologo /TC /Fovc_mswuhdll\wxregex_regcomp.obj /MD /
DWIN32 /Fd..
\..\lib\vc_dll\wxregexuh.pdb /O2 /D__NO_VC_CRTDBG__ /I..\..
\include /I..\..\l
ib\vc_dll\mswuh /D__WXMSW__ /D_UNICODE ..\..\src\regex\regcomp.c
regcomp.c

BTW, after running: nmake.exe -f makefile.vc UNICODE=1 MSLU=1
OFFICIAL_BUILD=1 SHARED=1
MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1 CXXFLAGS=/D__NO_VC_CRTDBG__
DEBUG_FLAG=1 WXDEBUGFLAG=h BUILD=release

Here is some output, looks like no wxdebug defined. is that the
reason? thank you.

Yes, that would be my guess as well.

         cl /EP /nologo "..\..\include\wx\msw\genrcdefs.h"> "..\..\lib
\vc_dll\ms
wuh\wx\msw\rcdefs.h"
genrcdefs.h
         cl /c /nologo /TC /Fovc_mswuhdll\wxregex_regcomp.obj /MD /
DWIN32 /Fd..
\..\lib\vc_dll\wxregexuh.pdb /O2 /D__NO_VC_CRTDBG__ /I..\..
\include /I..\..\l
ib\vc_dll\mswuh /D__WXMSW__ /D_UNICODE ..\..\src\regex\regcomp.c
regcomp.c

However it won't be set for these files anyway. Wait until it gets past the 3rd-party libraries (regex, image libs, etc.) and starts compiling wx source. Make sure that __WXDEBUG__ is defined for those compiles.

···

On 12/29/10 12:33 PM, wofeib wrote:

--
Robin Dunn
Software Craftsman

Hi, Robin,

We guess right.

The compiler setting is defined wxdebug, but at the same time it
defined ndebug.
As you told me before, the ndebug will turn wxdebug off.

So I modified this line build/msw/makefile.vc: (added && "$
(DEBUG_FLAG)" == "0")

!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default" &&
"$(DEBUG_FLAG)" == "0"
__NDEBUG_DEFINE_p = /DNDEBUG
!endif

Now the problem is solved.

Thank you.

another question is regarding PYTHONPATH.

When I installed python, it already installed wxpython in lib\site-
packages, also wx.pth, wxversion.py.

In this case, which wxpython is using when I run demo.py?

thanks.

From: wofeib

Sent: Thursday, December 30, 2010 3:41 PM

To: wxPython-users

Subject: [wxPython-users] Re: build wxPython 2.8

another question is regarding PYTHONPATH.

When I installed python, it already installed wxpython in lib\site-

packages, also wx.pth, wxversion.py.

In this case, which wxpython is using when I run demo.py?

Try adding to demo.py a line such as:

print wx.version()

after the line that imports wx.

Gadget/Steve

···

-----Original Message-----

thanks.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

another question is regarding PYTHONPATH.

When I installed python, it already installed wxpython in lib\site-
packages, also wx.pth, wxversion.py.

In this case, which wxpython is using when I run demo.py?

thanks.

From nmake.exe I conclude you are on Windows.

That's a pure Python job.

For *every* installed Python version, c:\Python25,
c:\Python26, c:\Python27 , ..., you have

- a sys.path
- a lib\site-packages containing one or more "wxPython's"
- a wx.pth defining a default wxPython version by *extending
  the sys.path*
- a wxversion module allowing to select the wxPython
  version if you do not use the default (wx.pth) version.

Now running a *Python* script (.py, .pyw), can be the demo.py,
will just follow the Python rules as defined above.

Example:

If wxPython is installed in/as
C:\Python27\Lib\site-packages\wx-2.9.1-msw
and
wx.pth points to wx-2.9.1-msw
a command like

c:\Python27\python.exe demo.py

will use "python27" and "wxPython 2.9.1".

(indepedently of any PYTHONPATH env)

You have to be sure to use a demo.py version
corresponding to the correct Python and wxPython
version. The demo.py does not use wxversion, since
there is a demo for every Python/wxPython version.

jmf

···

On Dec 30, 4:41 pm, wofeib <abb...@gmail.com> wrote:

Thank you for help, Steve and jmf.

Now my question is:

I want to build my application in both debug and release mode. I build
wxwidgets and wxpython in both debug and release mode.
so now how to tell my application to link to different version of
wxpython?

Thanks.

No idea. My guess is to have two different "wxPython" in two
different \site-packages\wx-*** directories and to toy with
the wx.pth, dir names or sys.path.

That's the trick I'm using to work comfortably with the
different (and *incompatible*) wx-2.8.* versions I installed
in parallel.

jmf

···

On Dec 30, 6:54 pm, wofeib <abb...@gmail.com> wrote:

Thank you for help, Steve and jmf.

Now my question is:

I want to build my application in both debug and release mode. I build
wxwidgets and wxpython in both debug and release mode.
so now how to tell my application to link to different version of
wxpython?

Thanks.

You can run the debug and the release versions from the build dir if you want, that way you won't have to worry about clobbering the official release in the installed location. Just set PYTHONPATH to the wxPython folder in the source tree, and then "import wx" will use the wxPython/wx package dir from the source tree. You can have both the debug and the release builds there, and if you copy the wx DLLs to that wxPython/wx dir then you don't have to worry about setting the PATH to ensure that the ones you built are the ones found first.

To test that your PYTHONPATH is set correctly you can do "import wx; print wx.__file__" to see which wxPython is being loaded.

···

On 12/30/10 9:54 AM, wofeib wrote:

Thank you for help, Steve and jmf.

Now my question is:

I want to build my application in both debug and release mode. I build
wxwidgets and wxpython in both debug and release mode.
so now how to tell my application to link to different version of
wxpython?

--
Robin Dunn
Software Craftsman

You can run the debug and the release versions from the build dir if you
want, that way you won't have to worry about clobbering the official
release in the installed location. Just set PYTHONPATH to the wxPython
folder in the source tree, and then "import wx" will use the wxPython/wx
package dir from the source tree. You can have both the debug and the
release builds there, and if you copy the wx DLLs to that wxPython/wx
dir then you don't have to worry about setting the PATH to ensure that
the ones you built are the ones found first.

To test that your PYTHONPATH is set correctly you can do "import wx;
print wx.__file__" to see which wxPython is being loaded.

I didn't achieve that.

I set PYTHONPATH = ${WXWIN}\wxpython in the environment variables.

when running my application in release mode, print wx.__file__
outputs
"${WXWIN}\wxPython\wx\__init__.pyc" and it makes sense.

However, when running my application in debug mode, import wx gets
error.
I'm wondering if I should use _core__d instead. If yes, how to do it?
Thanks.

···

------------------------------------------------------------
Traceback (most recent call last):
     ...
    import wx
  File "D:\wxPython-src-2.8.11.0\wxPython\wx\__init__.py", line 45, in
<module>
    from wx._core import *
  File "D:\wxPython-src-2.8.11.0\wxPython\wx\_core.py", line 4, in
<module>
    import _core_
ImportError: DLL load failed: A dynamic link library (DLL)
initialization routine failed.
------------------------------------------------------------

another question:

how to convert parameter from 'wxChar **' to 'char **'?

because I'm using UNICODE now, so argv is wxChar **, but part of my
code needs argv is Char **

thank you.

wofeib wrote:

another question:

how to convert parameter from 'wxChar **' to 'char **'?

because I'm using UNICODE now, so argv is wxChar **, but part of my
code needs argv is Char **

Well, there's no shortcut for this. If you have no other choice, you
will have to create a separate array, allocate the individual strings,
and convert them with wcstombs.

It might be better to change your other code to be able to handle either
type, using the TCHAR type.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

You can run the debug and the release versions from the build dir if you
want, that way you won't have to worry about clobbering the official
release in the installed location. Just set PYTHONPATH to the wxPython
folder in the source tree, and then "import wx" will use the wxPython/wx
package dir from the source tree. You can have both the debug and the
release builds there, and if you copy the wx DLLs to that wxPython/wx
dir then you don't have to worry about setting the PATH to ensure that
the ones you built are the ones found first.

To test that your PYTHONPATH is set correctly you can do "import wx;
print wx.__file__" to see which wxPython is being loaded.

I didn't achieve that.

I set PYTHONPATH = ${WXWIN}\wxpython in the environment variables.

when running my application in release mode, print wx.__file__
outputs
"${WXWIN}\wxPython\wx\__init__.pyc" and it makes sense.

However, when running my application in debug mode, import wx gets
error.
I'm wondering if I should use _core__d instead. If yes, how to do it?

The _d version of extension modules is used automatically when using the debug build of Python on Windows.

Traceback (most recent call last):
      ...
     import wx
   File "D:\wxPython-src-2.8.11.0\wxPython\wx\__init__.py", line 45, in
<module>
     from wx._core import *
   File "D:\wxPython-src-2.8.11.0\wxPython\wx\_core.py", line 4, in
<module>
     import _core_
ImportError: DLL load failed: A dynamic link library (DLL)
initialization routine failed.

Use Dependency Walker to see what DLL is having problems and you may also be able to get a clue as to why.

···

On 1/3/11 7:40 AM, wofeib wrote:

--
Robin Dunn
Software Craftsman

Just create a wxString from the argv values and then use ToAscii or one of the other conversion methods to get what you want. Or one of the wxMBConv classes can be used without creating a wxString first, but that is a bit more complex. See the docs.

···

On 1/3/11 10:52 AM, wofeib wrote:

another question:

how to convert parameter from 'wxChar **' to 'char **'?

because I'm using UNICODE now, so argv is wxChar **, but part of my
code needs argv is Char **

--
Robin Dunn
Software Craftsman

Thanks Robin, I figure out my problem:
I didn't use python26_d.lib. Actually I'm using python26.lib for both
debug and release.
python26.lib will only know _core_.pyd. in Dependency Walker, I also
see this point.

Since I don't want to touch python part and build python in debug
mode. The only thing
I can do is to rename all *_d.pyd to *.pyd. So I ended up two folders,
one debug folder
and one release folder, each has 20 wxpython libs.

When I build my application in debug mode, I put all libs in debug
folder in wxpython/wx,
it succeeds. When I build my application in release mode, I put all
libs in release folder
in wxpython/wx, it also succeeds.

Now the problem is: I don't want to copy/paste every time. Then how to
tell wx load libs
from debug folder when I build application in debug mode?

Here is my tree:
-wx
---lib
---locale
---debug
------_core_.pyd
------_grid_.pyd
------............
---release
------_core_.pyd
------_grid_.pyd

Thanks Robin, I figure out my problem:
I didn't use python26_d.lib. Actually I'm using python26.lib for both
debug and release.
python26.lib will only know _core_.pyd. in Dependency Walker, I also
see this point.

Since I don't want to touch python part and build python in debug
mode.

It's been a long time since I tried this but since you are embedding Python in your application all you should need is to add Python's project files to your solution and adjust your dependencies and your include and library paths.

Now the problem is: I don't want to copy/paste every time. Then how to
tell wx load libs
from debug folder when I build application in debug mode?

Set PYTHONPATH as needed in each of your build/run configs

···

On 1/3/11 12:21 PM, wofeib wrote:

--
Robin Dunn
Software Craftsman

Set PYTHONPATH as needed in each of your build/run configs

I already set PYTHONPATH = $WXWIN\wxpython.

did you mean adding "$WXWIN\wxpython\wx\debug" and "$WXWIN\wxpython\wx
\release" to the PYTHONPATH also?
but there are exactly same files in these two folders, even though the
context of files are different.

I feel maybe something can be done in $WXWIN\wxpython\wx\__init__.py,
but I really don't know how.

before:
             # Load the package namespace with the core classes and
such
             from wx._core import *
             del wx

after:

             # Load the package namespace with the core classes and
such
             if current_build == debug:
                   from wx.debug._core import *
                   del wx
             else:
                   from wx.release._core import *
                   del wx

thank you for help again.