building mpl on windows for wx blitting

Hi all. Trying to build the next mpl release, and I am running into a
hurdle with wx. We are trying to include the _wxagg module in the
next release and this has not been done before. I am able to
successfully build wx under mingw, and the entire mpl compilation goes
fine until I hit the linking stage for _wxagg. Error output pasted
below. Googling these errors hasn't led me to anything obvious.
There are a lot of mentions of the vtable for xxx undefined
references. Does anybody have any clues?

Thanks,

···

--------------------------------------------------
building 'matplotlib.backends._wxagg' extension
gcc options: '-O2 -Wall -Wstrict-prototypes'
compile options: '-Iwin32_static\include -I. -Isrc -Iswig
-Iagg23/include -I. -Iwin32_static\include -I.
-Iwin32_static\include\freetype2 -I.\freetype2 -Isrc\freetype2
-Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2
-Iwin32_static\include\freetype2 -I.\freetype2 -Ic:\Python24\include
-Ic:\Python24\PC -c'
g++ -shared build\temp.win32-2.4\Release\src\_wxagg.o
build\temp.win32-2.4\Release\src\mplutils.o
build\temp.win32-2.4\Release\cxx\cxxsupport.o
build\temp.win32-2.4\Release\cxx\cxx_extensions.o
build\temp.win32-2.4\Release\cxx\indirectpythoninterface.o
build\temp.win32-2.4\Release\cxx\cxxextensions.o -Lwin32_static\lib
-Lwin32_static\lib -Lc:\Python24\libs -Lc:\Python24\PCBuild -lpng -lz
-lstdc++ -lm -lfreetype -lz -lgw32c -lstdc++ -lm -lwxmsw26 -lwxpng
-lwxregex -lwxzlib -lwxexpat -lwxjpeg -lwxtiff -lpython24 -lmsvcr71 -o
build\lib.win32-2.4\matplotlib\backends\_wxagg.pyd
build\temp.win32-2.4\Release\src\_wxagg.o(.text+0x7c3):_wxagg.cpp:
undefined reference to `wxImage::wxImage(int, int, unsigned char*,
bool)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x38d):_wxagg.cpp: undefined reference to
`wxImage::wxImage(wxImage const*)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3b8):_wxagg.cpp: undefined reference to `vtable for
wxBitmap'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3df):_wxagg.cpp: undefined reference to
`wxBitmap::CreateFromImage(wxImage const&, int)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3e6):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3fc):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x415):_wxagg.cpp: undefined reference to
`wxImage::Destroy()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x55d):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x56b):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x580):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x593):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
collect2: ld returned 1 exit status
--------------------------------------------------------------

I am now just using the provided wxPython2.6-win32-devel download
and getting the exact same error, after renaming all the .lib files to
.a. What version of wxPython was _wxagg originally built with?

···

On 1/6/06, Charlie Moad <cwmoad@...149...> wrote:

Hi all. Trying to build the next mpl release, and I am running into a
hurdle with wx. We are trying to include the _wxagg module in the
next release and this has not been done before. I am able to
successfully build wx under mingw, and the entire mpl compilation goes
fine until I hit the linking stage for _wxagg. Error output pasted
below. Googling these errors hasn't led me to anything obvious.
There are a lot of mentions of the vtable for xxx undefined
references. Does anybody have any clues?

Thanks,

--------------------------------------------------
building 'matplotlib.backends._wxagg' extension
gcc options: '-O2 -Wall -Wstrict-prototypes'
compile options: '-Iwin32_static\include -I. -Isrc -Iswig
-Iagg23/include -I. -Iwin32_static\include -I.
-Iwin32_static\include\freetype2 -I.\freetype2 -Isrc\freetype2
-Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2
-Iwin32_static\include\freetype2 -I.\freetype2 -Ic:\Python24\include
-Ic:\Python24\PC -c'
g++ -shared build\temp.win32-2.4\Release\src\_wxagg.o
build\temp.win32-2.4\Release\src\mplutils.o
build\temp.win32-2.4\Release\cxx\cxxsupport.o
build\temp.win32-2.4\Release\cxx\cxx_extensions.o
build\temp.win32-2.4\Release\cxx\indirectpythoninterface.o
build\temp.win32-2.4\Release\cxx\cxxextensions.o -Lwin32_static\lib
-Lwin32_static\lib -Lc:\Python24\libs -Lc:\Python24\PCBuild -lpng -lz
-lstdc++ -lm -lfreetype -lz -lgw32c -lstdc++ -lm -lwxmsw26 -lwxpng
-lwxregex -lwxzlib -lwxexpat -lwxjpeg -lwxtiff -lpython24 -lmsvcr71 -o
build\lib.win32-2.4\matplotlib\backends\_wxagg.pyd
build\temp.win32-2.4\Release\src\_wxagg.o(.text+0x7c3):_wxagg.cpp:
undefined reference to `wxImage::wxImage(int, int, unsigned char*,
bool)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x38d):_wxagg.cpp: undefined reference to
`wxImage::wxImage(wxImage const*)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3b8):_wxagg.cpp: undefined reference to `vtable for
wxBitmap'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3df):_wxagg.cpp: undefined reference to
`wxBitmap::CreateFromImage(wxImage const&, int)'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3e6):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x3fc):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x415):_wxagg.cpp: undefined reference to
`wxImage::Destroy()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x55d):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x56b):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x580):_wxagg.cpp: undefined reference to `vtable for
wxObject'
build\temp.win32-2.4\Release\src\_wxagg.o(.text$_ZN13_wxagg_module24convert_agg_to_wx_bitmapERKN2Py5TupleE[_wxagg_module::convert_agg_to_wx_bitmap(Py::Tuple
const&)]+0x593):_wxagg.cpp: undefined reference to `wxObject::UnRef()'
collect2: ld returned 1 exit status
--------------------------------------------------------------

I was able to find one clear explanation of what g++ means when it starts carrying on about undefined references to vtables:

  http://gcc.gnu.org/ml/gcc-bugs/2002-09/msg00083.html

It sounds to me like a build environment problem, but I can't see any obvious problems in the output you pasted.

Ken

···

On Jan 6, 2006, at 12:11 PM, Charlie Moad wrote:

Googling these errors hasn't led me to anything obvious.
There are a lot of mentions of the vtable for xxx undefined
references. Does anybody have any clues?

     I am now just using the provided wxPython2.6-win32-devel download
and getting the exact same error, after renaming all the .lib files to
.a.

Curiouser and curiouser. I'll try to get to a windows machine later today and attempt to reproduce/diagnose the problem.

What version of wxPython was _wxagg originally built with?

It was originally developed using version 2.5.3.1 under Mac OS 10.3.

Ken

···

On Jan 6, 2006, at 1:04 PM, Charlie Moad wrote:

I was on the wx list a little and got some help, but no solutions.
Basically I get the same linker errors if I pass no wx libs, so mingw
is not finding any symbols in the libraries. It is not complaining
about the libraries either. Someone on the list said the c++ symbols
are mangled by visual studio, so the only way to get it to work is
compile _wxagg wil vs. Kinda hit a road block now.

···

On 1/7/06, Ken McIvor <mcivor@...227...> wrote:

On Jan 6, 2006, at 1:04 PM, Charlie Moad wrote:
> I am now just using the provided wxPython2.6-win32-devel download
> and getting the exact same error, after renaming all the .lib files to
> .a.

Curiouser and curiouser. I'll try to get to a windows machine later
today and attempt to reproduce/diagnose the problem.

> What version of wxPython was _wxagg originally built with?

It was originally developed using version 2.5.3.1 under Mac OS 10.3.

Ken

I was on the wx list a little and got some help, but no solutions.
Basically I get the same linker errors if I pass no wx libs, so mingw
is not finding any symbols in the libraries. It is not complaining
about the libraries either.

That's pretty strange behavior in a compiler. The compiler output you posted earlier doesn't make it clear how your build environment was set up. It seems to me that the _wxagg extension must be built using the wxPython-win32-devel headers and libraries to ensure compatibility with the current stable version of wxPython and wxWidgets.

This may result in an extension that only works with one version of wxPython. I'm not sure how best to deal with that situation in a binary distribution. It may be to build a _wxagg extension for several versions of wxPython and select the right one at run time.

Someone on the list said the c++ symbols are mangled by visual studio,
so the only way to get it to work is compile _wxagg wil vs.

That's something I hadn't considered before now, but is no doubt the case. There isn't a standard application binary interface for C++ compilers, so they tend to use different name mangling schemes to discourage you from shooting your foot (e.g. by linking incompatible object files together into an application that doesn't work).

I'm afraid I'm not going to be of much help here, since don't have easy access to a windows computer. I just got back from the lab, where I spent several hours trying to get the build environment setup so I could build matplotlib. I gave up in the end, having failed to get the Agg backend to build due to weird linking errors.

If anyone needs me I'll be hugging my iBook and crying. :wink:

Ken

···

On Jan 7, 2006, at 3:33 PM, Charlie Moad wrote:

That's pretty strange behavior in a compiler. The compiler output
you posted earlier doesn't make it clear how your build environment
was set up. It seems to me that the _wxagg extension must be built
using the wxPython-win32-devel headers and libraries to ensure
compatibility with the current stable version of wxPython and wxWidgets.

I ended up using their win-devel pkg and got the same results.

Well, decision time. Should we go ahead and push a mpl release
without wx blitting on windows? I personally think there have been
more than enough changes to justify it.

- Charlie

I ended up using their win-devel pkg and got the same results.

If wxPython was built with Microsoft Visual C++, then this behavior makes some kind of sense. Should matplotlib be built with VC++, I'd still recommend using the win-devel package to ensure compatibility with the stable version of wxPython.

Well, decision time. Should we go ahead and push a mpl release
without wx blitting on windows? I personally think there have been
more than enough changes to justify it.

By all means. WXAgg still works without the _wxagg module, as does FigureCanvasWxAgg.blit(). It's just slower, because the Agg- >wx.Bitmap conversion is done in pure Python when the _wxagg module isn't present.

Ken

···

On Jan 8, 2006, at 9:55 AM, Charlie Moad wrote: