Windows build problems

I would like to integrate wxPython support into my application that is built with C++ and wxWidgets. I got the 2.8.6.0 source distribution of wxPython and set about getting it built, but unfortunately I can’t get it to build. I’ve followed the Windows build instructions exactly, and just to be extra sure I tried a clean build using the version of wxWidgets contained in the wxPython source distribution. wxWidgets builds fine, but when running setup.py to build wxPython I get linker errors from MSVC complaining about wxString::Cmp(), wxString::Printf() et. al. It appears that when building wxPython, it thinks that wxChar is an unsigned short rather than wchar_t - even though I build wxWidgets with Unicode support and passed the appropriate Unicode flags when trying to build wxPython.

Do any of these problems sound familiar? Am I missing something simple here?

Thanks,

  • Jamie

Jamie Redmond wrote:

I would like to integrate wxPython support into my application that is built with C++ and wxWidgets. I got the 2.8.6.0 source distribution of wxPython and set about getting it built, but unfortunately I can't get it to build. I've followed the Windows build instructions exactly, and just to be extra sure I tried a clean build using the version of wxWidgets contained in the wxPython source distribution. wxWidgets builds fine, but when running setup.py to build wxPython I get linker errors from MSVC complaining about wxString::Cmp(), wxString::Printf() et. al.

What are the actual errors?

It appears that when building wxPython, it thinks that wxChar is an unsigned short rather than wchar_t - even though I build wxWidgets with Unicode support and passed the appropriate Unicode flags when trying to build wxPython.

Depending on the compiler wchar_t may just be a typedef for unsigned short.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

What are the actual errors?

I'm trying to do everything the default out-of-the-box way, so I'm following the instructions in build.txt exactly with a fresh distribution zip. I copied setup0.h to setup.h and changed all of the settings as described (I'm using Unicode). I built wxWidgets with the following command and it build just fine:

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

Next I attempt to build wxPython like so:

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

So far I've followed the instructions in build.txt exactly, but the build fails on _core_wrap.cpp (sorry for the formatting):

_core_wrap.cpp
src\msw\_core_wrap.cpp(4419) : warning C4996: 'wxSizer::Remove' was declared deprecated
        ..\include\wx\sizer.h(499) : see declaration of 'wxSizer::Remove'
src\msw\_core_wrap.cpp(32984) : warning C4996: 'wxGetAccelFromString' was declared deprecated
        ..\include\wx\utils.h(573) : see declaration of 'wxGetAccelFromString'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:..\lib\vc_dll /LIBPATH:C:\Python25\libs /LIBPATH:C:\Py
thon25\PCBuild wxbase28uh.lib wxbase28uh_net.lib wxbase28uh_xml.lib wxmsw28uh_core.lib wxmsw28uh_adv.lib wxmsw28uh_html.lib kernel32.lib user32.lib gdi32.lib co
mdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib /EXPORT:i
nit_core_ build.unicode\temp.win32-2.5\Release\src/helpers.obj build.unicode\temp.win32-2.5\Release\src/wxc.res build.unicode\temp.win32-2.5\Release\src\msw\_co
re_wrap.obj /OUT:wx\_core_.pyd /IMPLIB:build.unicode\temp.win32-2.5\Release\src\_core_.lib
   Creating library build.unicode\temp.win32-2.5\Release\src\_core_.lib and object build.unicode\temp.win32-2.5\Release\src\_core_.exp
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(unsigned short const *,int,char const *,unsigned short co
nst *,unsigned short const *)" (__imp_?wxOnAssert@@YAXPBGHPBD00@Z) referenced in function "public: void __thiscall wxMemoryBuffer::SetDataLen(unsigned int)" (?S
etDataLen@wxMemoryBuffer@@QAEXI@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(unsigned short const *,int,char const *,unsigned short
const *,unsigned short const *)" (__imp_?wxOnAssert@@YAXPBGHPBD00@Z) referenced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall wxString::Cmp(unsigned short const *)const " (__imp_?Cmp@w
xString@@QBEHPBG@Z) referenced in function "bool __cdecl operator==(class wxString const &,unsigned short const *)" (??8@YA_NABVwxString@@PBG@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall wxString::wxString(unsigned short const *)" (__imp_??0wxString
@@QAE@PBG@Z) referenced in function "public: static class wxString __cdecl wxPyApp::GetMacHelpMenuTitleName(void)" (?GetMacHelpMenuTitleName@wxPyApp@@SA?AVwxStr
ing@@XZ)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall wxString::wxString(unsigned short const *)" (__imp_??0wxStr
ing@@QAE@PBG@Z) referenced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxEmptyString" (__imp_?wxEmptyString@@3PBGB) referen
ced in function "public: static class wxString __cdecl wxPyApp::GetMacHelpMenuTitleName(void)" (?GetMacHelpMenuTitleName@wxPyApp@@SA?AVwxString@@XZ)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxEmptyString" (__imp_?wxEmptyString@@3PBGB) refe
renced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned short * __thiscall wxString::GetWriteBuf(unsigned int)" (__imp_?
GetWriteBuf@wxString@@QAEPAGI@Z) referenced in function "class wxString * __cdecl wxString_in_helper(struct _object *)" (?wxString_in_helper@@YAPAVwxString@@PAU
_object@@@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned short __thiscall wxString::GetChar(unsigned int)const " (__imp_?
GetChar@wxString@@QBEGI@Z) referenced in function "bool __cdecl wxColour_helper(struct _object *,class wxColour * *)" (?wxColour_helper@@YA_NPAU_object@@PAPAVwx
Colour@@@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl wxString::Printf(unsigned short const *,...)" (__imp_?Printf@
wxString@@QAAHPBGZZ) referenced in function "bool __cdecl wxPyTwoIntItem_helper<class wxSize>(struct _object *,class wxSize * *,unsigned short const *)" (??$wxP
yTwoIntItem_helper@VwxSize@@@@YA_NPAU_object@@PAPAVwxSize@@PBG@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __cdecl wxString::Printf(unsigned short const *,...)" (__imp_?Prin
tf@wxString@@QAAHPBGZZ)
helpers.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsole::OnAssert(unsigned short const *,int,unsigned short const
*,unsigned short const *)" (?OnAssert@wxAppConsole@@UAEXPBGH00@Z)
helpers.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxApp::Initialize(int &,unsigned short * *)" (?Initialize@wxApp@@UAE_NA
AHPAPAG@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall wxAppConsole::OnAssertFailure(unsigned short cons
t *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (__imp_?OnAssertFailure@wxAppConsole@@UAEXPBGH000@Z) referenced in function "publ
ic: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (?OnAsser
tFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxLogDebug(unsigned short const *,...)" (__imp_?wxLogDebug@@YAXPBGZZ
) referenced in function "public: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsi
gned short const *)" (?OnAssertFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::operator<<(unsigned short const *)"
(__imp_??6wxString@@QAEAAV0@PBG@Z) referenced in function "public: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short c
onst *,unsigned short const *,unsigned short const *)" (?OnAssertFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::operator+=(unsigned short const *)"
(__imp_??YwxString@@QAEAAV0@PBG@Z) referenced in function "struct _object * __cdecl wxPyMake_wxObject(class wxObject *,bool,bool)" (?wxPyMake_wxObject@@YAPAU_o
bject@@PAVwxObject@@_N1@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxStringBase & __thiscall wxStringBase::operator=(unsigned short co
nst *)" (__imp_??4wxStringBase@@QAEAAV0@PBG@Z) referenced in function "struct _object * __cdecl wxPyMake_wxObject(class wxObject *,bool,bool)" (?wxPyMake_wxObje
ct@@YAPAU_object@@PAVwxObject@@_N1@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class wxStringBase & __thiscall wxStringBase::operator=(unsigned short
const *)" (__imp_??4wxStringBase@@QAEAAV0@PBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned long __cdecl wxStringHash::wxCharStringHash(unsigned s
hort const *)" (__imp_?wxCharStringHash@wxStringHash@@SAKPBG@Z) referenced in function "protected: static unsigned int __cdecl wxPyTypeInfoHashMap_wxImplementat
ion_HashTable::GetBucketForNode(class wxPyTypeInfoHashMap_wxImplementation_HashTable *,struct wxPyTypeInfoHashMap_wxImplementation_HashTable::Node *)" (?GetBuck
etForNode@wxPyTypeInfoHashMap_wxImplementation_HashTable@@KAIPAV1@PAUNode@1@@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall wxColourBase::FromString(unsigned short const *)" (?FromString@wx
ColourBase@@MAE_NPBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::Append(unsigned short const *)"
(__imp_?Append@wxString@@QAEAAV1@PBG@Z) referenced in function "struct swig_type_info * __cdecl wxPyFindSwigType(unsigned short const *)" (?wxPyFindSwigType@@YA
PAUswig_type_info@@PBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxPanelNameStr" (__imp_?wxPanelNameStr@@3QBGB) re
ferenced in function _$E54
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxControlNameStr" (__imp_?wxControlNameStr@@3QBGB
) referenced in function _$E60
wx\_core_.pyd : fatal error LNK1120: 19 unresolved externals
error: command '"c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe"' failed with exit status 1120

As an aside, in my actual project I turned off wx2.6 compatibility mode in setup.h and wxPython didn't like that either - and I regenerated the rename tables and re-ran swig. That's not a big deal because I can re-enable that flag in my own application with no ill effects, but then I get stuck on these same linker errors that I get with a stock distribution.

Thanks for the help.

- Jamie

Jamie Redmond wrote:

What are the actual errors?

I'm trying to do everything the default out-of-the-box way, so I'm following the instructions in build.txt exactly with a fresh distribution zip. I copied setup0.h to setup.h and changed all of the settings as described (I'm using Unicode). I built wxWidgets with the following command and it build just fine:

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

Next I attempt to build wxPython like so:

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

So far I've followed the instructions in build.txt exactly, but the build fails on _core_wrap.cpp (sorry for the formatting):

_core_wrap.cpp

Can you show the line just before this one? It should have "cl.exe" in it and show the command line parameters passed to the compiler.

helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(unsigned short const *,int,char const *,unsigned short co
nst *,unsigned short const *)" (__imp_?wxOnAssert@@YAXPBGHPBD00@Z)

This can happen if there is a mismatch between how __WXDEBUG__ is defined between wxMSW and wxPython. The others are a bit more puzzling however...

As an aside, in my actual project I turned off wx2.6 compatibility mode in setup.h and wxPython didn't like that either - and I regenerated the rename tables and re-ran swig. That's not a big deal because I can re-enable that flag in my own application with no ill effects, but then I get stuck on these same linker errors that I get with a stock distribution.

You've probably already done this a million times, but if not please make sure that you are starting with a clean wx source tree and that there isn't any chance that wxPython may be trying to link with some other build of wxMSW.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Can you show the line just before this one? It should have "cl.exe" in
it and show the command line parameters passed to the compiler.

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -I..\lib\vc_dll\mswuh -I..\include -I..\contrib\include -Ic:\Python25\include -Ic:\Python25\PC /Tpsrc\msw\_core_wrap.cpp /Fobuild.unicode\temp.win32-2.5\Release\src\msw\_core_wrap.obj /Gy
_core_wrap.cpp

I've pasted the entire spew after issuing the python setup.py command below my signature in this response.

This can happen if there is a mismatch between how __WXDEBUG__ is defined between wxMSW and wxPython. The others are a bit more puzzling however...

The compiler also prints this as it is working, which may be what is causing the assert errors:

cl : Command line warning D4025 : overriding '/DNDEBUG' with '/UNDEBUG'

In my own builds, I didn't get the assert errors because I was using FINAL=1; but for the purposes of this email thread I decided to use the build settings as documented in the build instructions.

You've probably already done this a million times, but if not please make sure that you are starting with a clean wx source tree and that there isn't any chance that wxPython may be trying to link with some other build of wxMSW.

It can't be using some other build of wxWidgets. I'm starting with the wx source tree that comes with the wxPython source distribution (wxPython-src-2.8.6.0), and I have no registry entries or environment variables for any other wx stuff; in fact, I've removed all other traces of wx from my system. You can see from the command line parameters passed to cl.exe that it is looking for the libs in the wxPython source tree: -I..\lib\vc_dll\mswuh and when I delete all of the libs there I get "can't find library" errors as expected. Before signing up for this list and posting this message, I spent a lot of time searching google and someone had these exact build errors back in 2006 but there was never any resolution to it. I attempted to integrate wxPython like this back in late 2007 and ran into these same issues so I shelved the wxPython integration due to lake of time to figure it out, but now I'm running into the same issues on a newer build. I'd really love to get wxPython working.

Can no one reproduce these errors? I've tried on several machines and end up with the same result.

- Jamie

Initial python setup.py run:

Preparing CORE...
Preparing GLCANVAS...
Preparing STC...
Preparing ACTIVEX...
Preparing GIZMOS...
running build_ext
building '_core_' extension
creating build.unicode
creating build.unicode\temp.win32-2.5
creating build.unicode\temp.win32-2.5\Release
creating build.unicode\temp.win32-2.5\Release\src
creating build.unicode\temp.win32-2.5\Release\src\msw
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -I..\lib\vc_dll\mswuh -I..\include -I..\contrib\include -Ic:\Python25\include -Ic:\Python25\PC /Tpsrc/helpers.cpp /Fobuild.unicode\temp.win32-2.5\Release\src/helpers.obj /Gy
helpers.cpp
cl : Command line warning D4025 : overriding '/DNDEBUG' with '/UNDEBUG'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\rc.exe -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -I..\lib\vc_dll\mswuh -I..\include -I..\contrib\include -Ic:\Python25\include -Ic:\Python25\PC /fobuild.unicode\temp.win32-2.5\Release\src/wxc.res src/wxc.rc
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -I..\lib\vc_dll\mswuh -I..\include -I..\contrib\include -Ic:\Python25\include -Ic:\Python25\PC /Tpsrc\msw\_core_wrap.cpp /Fobuild.unicode\temp.win32-2.5\Release\src\msw\_core_wrap.obj /Gy
_core_wrap.cpp
cl : Command line warning D4025 : overriding '/DNDEBUG' with '/UNDEBUG'
src\msw\_core_wrap.cpp(4419) : warning C4996: 'wxSizer::Remove' was declared deprecated
        ..\include\wx\sizer.h(499) : see declaration of 'wxSizer::Remove'
src\msw\_core_wrap.cpp(32984) : warning C4996: 'wxGetAccelFromString' was declared deprecated
        ..\include\wx\utils.h(573) : see declaration of 'wxGetAccelFromString'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:..\lib\vc_dll /LIBPATH:c:\Python25\libs /LIBPATH:c:\Python25\PCBuild wxbase28uh.lib wxbase28uh_net.lib wxbase28uh_xml.lib wxmsw28uh_core.lib wxmsw28uh_adv.lib wxmsw28uh_html.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib /EXPORT:init_core_ build.unicode\temp.win32-2.5\Release\src/helpers.obj build.unicode\temp.win32-2.5\Release\src/wxc.res build.unicode\temp.win32-2.5\Release\src\msw\_core_wrap.obj /OUT:wx\_core_.pyd /IMPLIB:build.unicode\temp.win32-2.5\Release\src\_core_.lib
   Creating library build.unicode\temp.win32-2.5\Release\src\_core_.lib and object build.unicode\temp.win32-2.5\Release\src\_core_.exp
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(unsigned short const *,int,char const *,unsigned short const *,unsigned short const *)" (__imp_?wxOnAssert@@YAXPBGHPBD00@Z) referenced in function "public: void __thiscall wxMemoryBuffer::SetDataLen(unsigned int)" (?SetDataLen@wxMemoryBuffer@@QAEXI@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(unsigned short const *,int,char const *,unsigned short const *,unsigned short const *)" (__imp_?wxOnAssert@@YAXPBGHPBD00@Z) referenced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall wxString::Cmp(unsigned short const *)const " (__imp_?Cmp@wxString@@QBEHPBG@Z) referenced in function "bool __cdecl operator==(class wxString const &,unsigned short const *)" (??8@YA_NABVwxString@@PBG@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall wxString::wxString(unsigned short const *)" (__imp_??0wxString@@QAE@PBG@Z) referenced in function "public: static class wxString __cdecl wxPyApp::GetMacHelpMenuTitleName(void)" (?GetMacHelpMenuTitleName@wxPyApp@@SA?AVwxString@@XZ)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall wxString::wxString(unsigned short const *)" (__imp_??0wxString@@QAE@PBG@Z) referenced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxEmptyString" (__imp_?wxEmptyString@@3PBGB) referenced in function "public: static class wxString __cdecl wxPyApp::GetMacHelpMenuTitleName(void)" (?GetMacHelpMenuTitleName@wxPyApp@@SA?AVwxString@@XZ)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxEmptyString" (__imp_?wxEmptyString@@3PBGB) referenced in function _init_core_
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned short * __thiscall wxString::GetWriteBuf(unsigned int)" (__imp_?GetWriteBuf@wxString@@QAEPAGI@Z) referenced in function "class wxString * __cdecl wxString_in_helper(struct _object *)" (?wxString_in_helper@@YAPAVwxString@@PAU_object@@@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned short __thiscall wxString::GetChar(unsigned int)const " (__imp_?GetChar@wxString@@QBEGI@Z) referenced in function "bool __cdecl wxColour_helper(struct _object *,class wxColour * *)" (?wxColour_helper@@YA_NPAU_object@@PAPAVwxColour@@@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl wxString::Printf(unsigned short const *,...)" (__imp_?Printf@wxString@@QAAHPBGZZ) referenced in function "bool __cdecl wxPyTwoIntItem_helper<class wxSize>(struct _object *,class wxSize * *,unsigned short const *)" (??$wxPyTwoIntItem_helper@VwxSize@@@@YA_NPAU_object@@PAPAVwxSize@@PBG@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __cdecl wxString::Printf(unsigned short const *,...)" (__imp_?Printf@wxString@@QAAHPBGZZ)
helpers.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsole::OnAssert(unsigned short const *,int,unsigned short const *,unsigned short const *)" (?OnAssert@wxAppConsole@@UAEXPBGH00@Z)
helpers.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxApp::Initialize(int &,unsigned short * *)" (?Initialize@wxApp@@UAE_NAAHPAPAG@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall wxAppConsole::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (__imp_?OnAssertFailure@wxAppConsole@@UAEXPBGH000@Z) referenced in function "public: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (?OnAssertFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxLogDebug(unsigned short const *,...)" (__imp_?wxLogDebug@@YAXPBGZZ) referenced in function "public: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (?OnAssertFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::operator<<(unsigned short const *)" (__imp_??6wxString@@QAEAAV0@PBG@Z) referenced in function "public: virtual void __thiscall wxPyApp::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (?OnAssertFailure@wxPyApp@@UAEXPBGH000@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::operator+=(unsigned short const *)" (__imp_??YwxString@@QAEAAV0@PBG@Z) referenced in function "struct _object * __cdecl wxPyMake_wxObject(class wxObject *,bool,bool)" (?wxPyMake_wxObject@@YAPAU_object@@PAVwxObject@@_N1@Z)
helpers.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxStringBase & __thiscall wxStringBase::operator=(unsigned short const *)" (__imp_??4wxStringBase@@QAEAAV0@PBG@Z) referenced in function "struct _object * __cdecl wxPyMake_wxObject(class wxObject *,bool,bool)" (?wxPyMake_wxObject@@YAPAU_object@@PAVwxObject@@_N1@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class wxStringBase & __thiscall wxStringBase::operator=(unsigned short const *)" (__imp_??4wxStringBase@@QAEAAV0@PBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned long __cdecl wxStringHash::wxCharStringHash(unsigned short const *)" (__imp_?wxCharStringHash@wxStringHash@@SAKPBG@Z) referenced in function "protected: static unsigned int __cdecl wxPyTypeInfoHashMap_wxImplementation_HashTable::GetBucketForNode(class wxPyTypeInfoHashMap_wxImplementation_HashTable *,struct wxPyTypeInfoHashMap_wxImplementation_HashTable::Node *)" (?GetBucketForNode@wxPyTypeInfoHashMap_wxImplementation_HashTable@@KAIPAV1@PAUNode@1@@Z)
_core_wrap.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall wxColourBase::FromString(unsigned short const *)" (?FromString@wxColourBase@@MAE_NPBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString & __thiscall wxString::Append(unsigned short const *)" (__imp_?Append@wxString@@QAEAAV1@PBG@Z) referenced in function "struct swig_type_info * __cdecl wxPyFindSwigType(unsigned short const *)" (?wxPyFindSwigType@@YAPAUswig_type_info@@PBG@Z)
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxPanelNameStr" (__imp_?wxPanelNameStr@@3QBGB) referenced in function _$E54
_core_wrap.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * const wxControlNameStr" (__imp_?wxControlNameStr@@3QBGB) referenced in function _$E60
wx\_core_.pyd : fatal error LNK1120: 19 unresolved externals
error: command '"c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe"' failed with exit status 1120

Jamie Redmond wrote:

Can you show the line just before this one? It should have "cl.exe" in
it and show the command line parameters passed to the compiler.

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWIN32 -D_WINDOWS -D__WXMSW__ -DWXUSINGDLL=1 -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D__NO_VC_CRTDBG__ -D__WXDEBUG__ -DwxUSE_UNICODE=1 -Iinclude -Isrc -I..\lib\vc_dll\mswuh -I..\include -I..\contrib\include -Ic:\Python25\include -Ic:\Python25\PC /Tpsrc\msw\_core_wrap.cpp /Fobuild.unicode\temp.win32-2.5\Release\src\msw\_core_wrap.obj /Gy
_core_wrap.cpp

I've pasted the entire spew after issuing the python setup.py command below my signature in this response.

This can happen if there is a mismatch between how __WXDEBUG__ is defined between wxMSW and wxPython. The others are a bit more puzzling however...

The compiler also prints this as it is working, which may be what is causing the assert errors:

cl : Command line warning D4025 : overriding '/DNDEBUG' with '/UNDEBUG'

No that is normal. The /DNDEBUG is coming from distutils, and the /UNDEBUG is being explicitly added to turn off that define by our config.py.

In my own builds, I didn't get the assert errors because I was using FINAL=1; but for the purposes of this email thread I decided to use the build settings as documented in the build instructions.

You've probably already done this a million times, but if not please make sure that you are starting with a clean wx source tree and that there isn't any chance that wxPython may be trying to link with some other build of wxMSW.

It can't be using some other build of wxWidgets. I'm starting with the wx source tree that comes with the wxPython source distribution (wxPython-src-2.8.6.0),

Is 2.8.6 a requirement, or could you try 2.8.8? It may help to eliminate that as a difference between your machine and mine.

and I have no registry entries or environment variables for any other wx stuff; in fact, I've removed all other traces of wx from my system. You can see from the command line parameters passed to cl.exe that it is looking for the libs in the wxPython source tree: -I..\lib\vc_dll\mswuh and when I delete all of the libs there I get "can't find library" errors as expected. Before signing up for this list and posting this message, I spent a lot of time searching google and someone had these exact build errors back in 2006 but there was never any resolution to it. I attempted to integrate wxPython like this back in late 2007 and ran into these same issues so I shelved the wxPython integration due to lake of time to figure it out, but now I'm running into the same issues on a newer build. I'd really love to get wxPython working.

Can no one reproduce these errors? I've tried on several machines and end up with the same result.

The only difference between the compile and link command lines that you showed and the build I just did was that the path names to the compiler and linker are different (because I didn't use the default install location) and I used the full path name to the wx root dir. The only thing left that I can think of is that there is some difference in your wxWidgets build. Here is the nmake command that my scripts construct and use for the "hybrid" build:

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

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Is 2.8.6 a requirement, or could you try 2.8.8? It may help to eliminate that as a difference between your machine and mine.

Unfortunately, yes, I think so. My application uses wxWidgets 2.8.6, and it is quite painful to update as my application is over 200,000 lines of code and it also gets compiled into a massive (1 million+ lines of code) application that also uses wxWidgets 2.8.6.

The only difference between the compile and link command lines that you showed and the build I just did was that the path names to the compiler and linker are different (because I didn't use the default install location) and I used the full path name to the wx root dir. The only thing left that I can think of is that there is some difference in your wxWidgets build. Here is the nmake command that my scripts construct and use for the "hybrid" build:

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

This is the same command that I use manually. The version of wxWidgets I've been using for now is the version that actually comes with the wxPython source distribution. I manually changed setup.h like the build instructions said, but I do recall that the build instructions mention that your build scripts modify that file as well, so maybe it's possible your build script is doing something in that file that isn't obvious from the build instructions. I'll try compiling 2.8.8 manually to see if I can reproduce this, but if 2.8.8 works, it's unlikely I'll be able to use is. I can update my code to whatever wxWidgets version I want, but I am slaved to the version used in the 1 million+ LOC application, and getting that company to update to a new version is like pulling teeth.

- Jamie