Errors linking wxWidgets 2.8.12 in Lubuntu 11.10

Hey everyone,

I know this isn't a wxWidgets 'forum', but their forums take forever to 'approve' a post, and I was hoping to get some help with my g++ linker error soon'ish.

Here's the deal: I was able to compile my program just fine about an hour ago. I then made some changes that would not compile, so I undid the changes and tried to compile again, only to find all of these linking errors. At the same time I was doing all of this, I was upgrading Lubuntu from 11.04 to 11.10 in the background.

The `wx-config --cxxflags` bit in my compilation step below resolves to -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread, and the `wx-config --libs` bit resolves to -L/usr/local/lib -pthread -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lwx_gtk2_qa-2.8 -lwx_gtk2_html-2.8 -lwx_gtk2_adv-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8 -lwx_base_net-2.8 -lwx_base-2.8. These are basically 'shortcuts' to get the correct includes/libraries for the g++ compiler/linker.

Now, for some reason, it's telling me every other wx element/method/etc I call/use is undefined. But it didn't do this in Lubuntu 11.04! Very wierd. I think 11.10 upgraded to g++ 4.6 from 4.5 in 11.04. However, I tried to compile with the command g++-4.5 -g -02 ...etc..., but got the same errors...

Here's the output when I compile:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
jarrett@jarrett-Latitude-D520:~/Projects/WeightManager/build$ make
make  all-recursive
make[1]: Entering directory `/home/jarrett/Projects/WeightManager/build'
Making all in src
make[2]: Entering directory `/home/jarrett/Projects/WeightManager/build/src'
g++ -DHAVE_CONFIG_H -I. -I../../src -I..  `wx-config --cxxflags`    -g -O2 -g -O2 -MT WMWindow.o -MD -MP -MF .deps/WMWindow.Tpo -c -o WMWindow.o ../../src/WMWindow.cpp
mv -f .deps/WMWindow.Tpo .deps/WMWindow.Po
g++ -DHAVE_CONFIG_H -I. -I../../src -I..  `wx-config --cxxflags`    -g -O2 -g -O2 -MT WMMain.o -MD -MP -MF .deps/WMMain.Tpo -c -o WMMain.o ../../src/WMMain.cpp
mv -f .deps/WMMain.Tpo .deps/WMMain.Po
g++  -g -O2 -g -O2 `wx-config --libs`   -o WeightManager WMWindow.o WMMain.o  
WMWindow.o: In function `~WMWindow':
/home/jarrett/Projects/WeightManager/build/src/../../src/WMWindow.cpp:103: undefined reference to `wxAuiManager::UnInit()'
/home/jarrett/Projects/WeightManager/build/src/../../src/WMWindow.cpp:101: undefined reference to `wxAuiManager::~wxAuiManager()'
/home/jarrett/Projects/WeightManager/build/src/../../src/WMWindow.cpp:101: undefined reference to `wxAuiManager::~wxAuiManager()'
/home/jarrett/Projects/WeightManager/build/src/../../src/WMWindow.cpp:101: undefined reference to `wxFrame::~wxFrame()'
WMWindow.o: In function `wxGetTranslation':
/usr/local/include/wx-2.8/wx/intl.h:581: undefined reference to `wxGetLocale()'
WMWindow.o: In function `wxStringBase':
/usr/local/include/wx-2.8/wx/string.h:368: undefined reference to `wxStringBase::npos'
/usr/local/include/wx-2.8/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
...
(Lots of error lines removed for brevity)
...
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0x8c): undefined reference to `wxApp::WakeUpIdle()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0x90): undefined reference to `wxAppBase::CreateTraits()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0x94): undefined reference to `wxAppBase::MainLoop()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0x98): undefined reference to `wxAppBase::ExitMainLoop()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0x9c): undefined reference to `wxAppBase::Pending()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xa0): undefined reference to `wxAppBase::Dispatch()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xa4): undefined reference to `wxAppBase::ProcessIdle()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xa8): undefined reference to `wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&)'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xac): undefined reference to `wxAppBase::OnExceptionInMainLoop()'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xb4): undefined reference to `wxAppBase::GetTopWindow() const'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xb8): undefined reference to `wxAppBase::GetDisplayMode() const'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xc4): undefined reference to `wxAppBase::GetLayoutDirection() const'
WMMain.o:(.rodata._ZTV13WeightManager[vtable for WeightManager]+0xc8): undefined reference to `wxAppBase::SetActive(bool, wxWindow*)'
collect2: ld returned 1 exit status
make[2]: *** [WeightManager] Error 1
make[2]: Leaving directory `/home/jarrett/Projects/WeightManager/build/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/jarrett/Projects/WeightManager/build'
make: *** [all] Error 2
 


I've recompiled the wxWidgets 2.8.12 code and installed/ldconfig'd it, but I'm still having an issue. I've also restarted my machine.

I'm hitting a bit of a wall here. I know posting here is a bit of a stretch, but I could really use the help :)

I appreciate any input you guys/gals can provide.

Thanks!

Jarrett
Please note the line below, it generates those errors. The reason is that you didn't provide the library path and library name of wxWidgets to g++, so g++ cannot resolve the symbols in the error messages.

g++ -g -O2 -g -O2 `wx-config --libs` -o WeightManager WMWindow.o WMMain.o
Hey Eric,

Thanks for replying.

The line `wx-config --libs`makes the appropriate substitutions for inserting the library location and the name of the libraries needed.

Turns out, the issue is with Ubuntu 11.10 and (I suppose) gcc 4.6. 11.10 uses the ld flag --as-needed by default now, so the issue was with the ordering in the linker command...the object files now need to be BEFORE the library information. So, the appropriate linker command would now be:

g++ -g -O2 -g -O2 -o WeightManager WMWindow.o WMMain.o `wx-config --libs`

You can check out information on this issue here:
http://ubuntuforums.org/showthread.php?p=11347972&posted=1#post11347972

Thanks again for reading and replying to my post Eric!

Cheers

Jarrett
Topic archived. No new replies allowed.