#14741: unresolved externals for wxWindowList with VS11 (2012) and wxUSE_STD_CONTAINERS

13 views
Skip to first unread message

wxTrac

unread,
Oct 12, 2012, 9:24:04 AM10/12/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
--------------------------------+-------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version:
Keywords: vs11 visual studio | Blockedby:
Patch: 0 | Blocking:
--------------------------------+-------------------------------------------
I'm trying to compile my application with Visual Studio 2012 and get the
following unresolved externals from std::list<wxWindow*> when I have
wxUSE_STD_CONTAINERS defined:

This and others:
{{{
"__declspec(dllimport) public: static struct std::_List_node<class
wxWindow *,void *> * & __cdecl std::_List_val<struct
std::_List_simple_types<class wxWindow *> >::_Nextnode(struct
std::_List_node<class wxWindow *,void *> *)"
(__imp_?_Nextnode@?$_List_val@U?$_List_simple_types@PEAVwxWindow@@@std@@@
std@@SAAEAPEAU?$_List_node@PEAVwxWindow@@PEAX@2@PEAU32@@Z) referenced in
function "public: class std::_List_const_iterator<class
std::_List_val<struct std::_List_simple_types<class wxWindow *> > > &
__cdecl std::_List_const_iterator<class std::_List_val<struct
std::_List_simple_types<class wxWindow *> > >::operator++(void)"
(??E?$_List_const_iterator@V?$_List_val@U?$_List_simple_types@PEAVwxWindow
@@@std@@@std@@@std@@QEAAAEAV01@XZ)
}}}

Here is what I think happens:
In pre VS11 when an exported class derived from a template, the template
instance would in some instances be automatically exported as well. This
seems no longer to be the case.

window.h, line 145 (approx) has the following line
{{{
WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode,
class WXDLLIMPEXP_CORE);
}}}
This declares a class _dllexport/import wxWindowList, which derives from
std::list<wxWindow*> through some macro magic (WX_DECLARE_LIST_XO in
list.h, line 147)

The declaration is
class WXDLLIMPEXP_CORE wxWindowList:public std::list<wxWindow*> ...

Pre VS11 (VS9, Visual Studio 2008 to be precise) would seemingly export
all std::list members as well. But when I compile this code:
{{{
wxWindow *window;
for (wxWindowList::iterator i = window->GetChildren().begin(); i !=
window->GetChildren().end(); ++i)
}}}
I get the unresolved externals above.

Any Ideas? The way I see it, we have two choices:
1. Make wxWindowList a template itself or a header-only class. It is
currently being exported and there is a forward export declaration in
utils.h, line 57.
1. Explicitly instantiate std::list<wxWindow*> and export it. I think this
is possible with a non-standard Microsoft extension. This explicit
instantiation and export statement should reside somewhere in the wx-core
sources.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741>

wxTrac

unread,
Oct 12, 2012, 6:27:19 PM10/12/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:1>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
---------------------------+------------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 3.0
Component: wxMSW | Version:
Keywords: vs11 msvs dll | Blockedby:
Patch: 0 | Blocking:
---------------------------+------------------------------------------------
Changes (by vadz):

* keywords: vs11 visual studio => vs11 msvs dll
* milestone: => 3.0


Comment:

This is really strange, I have trouble believing that Microsoft could have
broken backwards compatibility so badly ''and'' that nobody noticed it.
But I don't see any other explanation neither...

Anyhow, we do have to fix it and if we can just remove export declaration
from `wxWindowList` to fix this, it would be the simplest and the best, of
course. Could you please confirm that it works (and attach a patch doing
this) please?

TIA!


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:1>

wxTrac

unread,
Oct 28, 2012, 11:42:42 AM10/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:2>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
---------------------------+------------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 3.0
Component: wxMSW | Version:
Keywords: vs11 msvs dll | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------
Changes (by hajokirchhoff):

* patch: 0 => 1


Comment:

Relatively straightforward though a bit more complicated than I expected:
The wxList classes are now header only and are no longer exported, but the
_WX_LIST_HELPER classes are still being exported. They do not derive from
a template class and don't have the problem described here.

Regarding "broken backwards compatibility...": my guess is that this was
never supposed to work anyway and only worked because of the previous way
the MS compiler instantiated templates. We probably disabled the warning
"base class needs to have dll export to be able to use members...", which
showed up in so many annoying places.

I've attached the patch. It works fine here now.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:2>

wxTrac

unread,
Oct 28, 2012, 11:45:14 AM10/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:3>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
---------------------------+------------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 3.0
Component: wxMSW | Version:
Keywords: vs11 msvs dll | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------

Comment(by hajokirchhoff):

On second thought: I tested the patch with wxUSE_STD_CONTAINERS but not
without. The changes should be transparent though, as I changed only the
#definition of the wxUSE_STD_CONTAINERS variant (I hope).


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:3>

wxTrac

unread,
Oct 28, 2012, 2:27:26 PM10/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:4>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
---------------------------+------------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.9.5
Component: wxMSW | Version:
Keywords: vs11 msvs dll | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------
Changes (by vadz):

* milestone: 3.0 => 2.9.5


Comment:

Thanks, I'll try to test and apply it soon.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:4>

wxTrac

unread,
Nov 9, 2012, 7:53:44 PM11/9/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:5>

#14741: unresolved externals for wxWindowList with VS11 (2012) and
wxUSE_STD_CONTAINERS
----------------------------+-----------------------------------------------
Reporter: hajokirchhoff | Owner:
Type: defect | Status: closed
Priority: normal | Milestone: 2.9.5
Component: wxMSW | Version:
Resolution: fixed | Keywords: vs11 msvs dll
Blockedby: | Patch: 1
Blocking: |
----------------------------+-----------------------------------------------
Changes (by VZ):

* status: new => closed
* resolution: => fixed


Comment:

(In [72940]) Fix link errors with VC 11 in DLL STL build.

Don't declare wxWindowList as DLL-exported. It's unnecessary and appears
to
create problems for VC 11.

Closes #14741.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14741#comment:5>
Reply all
Reply to author
Forward
0 new messages