Problems linking with Unicode enabled (Solved!)

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
kuactet
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Aug 20, 2006 4:27 pm

Problems linking with Unicode enabled (Solved!)

Post by kuactet » Sun Aug 20, 2006 5:25 pm

When I try to build my program with Unicode, I get a large set of error messages. It compiles and links fine without Unicode, but if I

#define wxUSE_UNICODE 1

in app.h then it does this:

Compiling source file(s)...
app.cpp
myframe.cpp
Linking...
\app.o:app.cpp:(.text+0xa7): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\app.o:app.cpp:(.rdata$_ZTV5MyApp[vtable for MyApp]+0x68): undefined reference to `wxApp::Initialize(int&, wchar_t**)'
\myframe.o:myframe.cpp:(.text+0x29c2): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x29dd): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x2aad): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x2ad0): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x2af6): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x2ebc): more undefined references to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)' follow
\myframe.o:myframe.cpp:(.text+0x37bc): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x37e5): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x390e): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3937): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3a0c): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3a35): more undefined references to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)' follow
\myframe.o:myframe.cpp:(.text+0x3bae): undefined reference to `wxString::Format(wchar_t const*, ...)'
\myframe.o:myframe.cpp:(.text+0x3bcb): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3c36): undefined reference to `wxString::Format(wchar_t const*, ...)'
\myframe.o:myframe.cpp:(.text+0x3c53): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3d55): undefined reference to `wxString::Format(wchar_t const*, ...)'
\myframe.o:myframe.cpp:(.text+0x3d72): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3ddd): undefined reference to `wxString::Format(wchar_t const*, ...)'
\myframe.o:myframe.cpp:(.text+0x3dfa): undefined reference to `wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x3f39): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text+0x4a26): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text$_ZN8wxStringC1EPKw[wxString::wxString(wchar_t const*)]+0x27): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
\myframe.o:myframe.cpp:(.text$_ZN8wxStringC1EPKw[wxString::wxString(wchar_t const*)]+0x4f): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
collect2: ld returned 1 exit status


What does this mean and how can I get it to go away (apart from not using Unicode)?


In case it's important, app.cpp is:

#include "app.h"
#include "myframe.h"
IMPLEMENT_APP(MyApp);
bool MyApp::OnInit() {
MyFrame* frame = new MyFrame(0L, wxT("Some Text Goes Here"));
frame->SetClientSize(600, 200);
frame->Centre();
frame->Show();
SetTopWindow(frame);
return true;
}



Thanks to MichaelWard for his solution!
Last edited by kuactet on Tue Aug 22, 2006 2:43 am, edited 1 time in total.

benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte » Mon Aug 21, 2006 2:28 pm

Most of the errors concern myframe.cpp, maybe you should post the code of this file.

PS: please use the [ code ] tag to format your source code (between Quote and List above the message editor). This makes it more readable.

MichaelWard
Knows some wx things
Knows some wx things
Posts: 38
Joined: Thu Jul 13, 2006 9:36 pm

Post by MichaelWard » Mon Aug 21, 2006 4:43 pm

I would check to make sure you are using the correct libraries etc. Just using the define isn't enough to change to unicode.

If you are using a DLL to link, you need to change all your library includes to use the unicode version. You most likely have to do this as well when using a static library as well.

When you build wxWidgets you choose whether ot build the unicode version or not. It usually puts a 'U' in the library filename.

For example
wxregex.lib - Is Release non-unicode
wxregexd.lib - is Debug non-unicode
wxregexu.lib - Is release unicode
wxregexud.lib - is Debug non-unicode

tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag » Tue Aug 22, 2006 8:08 am

wxregexud.lib - is Debug unicode
-tiwag

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Tue Aug 22, 2006 11:23 am

The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

Post Reply