Discussion:
Ordering wxWidgets libraries for successful linking
(too old to reply)
Jerome Breitenbach
2009-05-23 00:00:45 UTC
Permalink
I recently tried to introduce wxHtmlHelpController into an application.
But, the mere instantiation of the object--e.g.,
htmlHelpController = new wxHtmlHelpController;
--caused linking errors when the app was built. This happened despite
my having told my IDE (Code::Blocks, running GCC via MinGW) to link into
the build the needed wxHTML library (viz., libwxmsw28ud_html.a, for
wxWidgets 2.8.9 with a multi-lib build).

After some experimentation, though, I discovered that putting the wxHTML
library *first* in the Code::Blocks' list of the additional build
libraries solved the problem. Specifically, here is an ordering of the
additional libraries that produces a successful build:
libwxmsw28ud_html.a
libwxmsw28ud_core.a
libwxbase28ud.a
libwxpngd.a
libwxzlibd.a
This surprises me since, according to
http://docs.wxwidgets.org/trunk/page_libs.html, the wxHTML library
depends on the wxCore library (libwxmsw28ud_core.a); thus, I would
expect that if the order of these libraries is important (as it
apparently is), then wxCore should come first. Likewise, I found that
moving the wxBase library (libwxbase28ud.a) up one place in the above
list causes a linking error, despite the fact that the wxCore library
depends on the wxBase library.

What, then, are the ordering rules for linking additional wxWidgets
libraries into a project? (A pointer to some official documentation
will suffice.) Is it always the reverse order of the dependency (if
any)? Or, could it be that the order used by Code::Blocks / GCC itself
gets reversed before it performs the build? (BTW, the above list of
libraries, ordered as shown, is exactly what the Code::Blocks "Create a
new project" wizard provides for an empty project when the additional
wxHTML library is requested *within* the wizard.)

Thanks in advance,
Jerome
Vadim Zeitlin
2009-05-23 11:17:15 UTC
Permalink
On Fri, 22 May 2009 17:00:45 -0700 Jerome Breitenbach <***@calpoly.edu> wrote:

JB> This surprises me since, according to
JB> http://docs.wxwidgets.org/trunk/page_libs.html, the wxHTML library
JB> depends on the wxCore library (libwxmsw28ud_core.a); thus, I would
JB> expect that if the order of these libraries is important (as it
JB> apparently is), then wxCore should come first.

No, the dependencies should appear after the libraries/object files using
the symbols in them. Please see GNU ld documentation for details.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...