LNK2019 wxString::SubstrBufFromType

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
firescript
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Nov 26, 2019 1:26 am

LNK2019 wxString::SubstrBufFromType

Post by firescript »

Hello :
I get the following error when compiling the simple example:

Code: Select all

error LNK2019: unresolved external symbol "private: static struct wxString::SubstrBufFromType<class wxScopedCharTypeBuffer<unsigned short> > __cdecl wxString::ConvertStr(char const *,unsigned __int64,class wxMBConv const &)" (?ConvertStr@wxString@@CA?AU?$SubstrBufFromType@V?$wxScopedCharTypeBuffer@G@@@1@PEBD_KAEBVwxMBConv@@@Z) referenced in function "private: static class wxScopedCharTypeBuffer<unsigned short> __cdecl wxString::ImplStr(char const *,class wxMBConv const &)" (?ImplStr@wxString@@CA?AV?$wxScopedCharTypeBuffer@G@@PEBDAEBVwxMBConv@@@Z)
fatal error LNK1120: 1 unresolved externals
Unicode version
lib files as followed:
wxbase31u.lib wxbase31u_net.lib wxbase31u_xml.lib wxexpat.lib wxjpeg.lib wxmsw31u_aui.lib wxmsw31u_core.lib wxmsw31u_gl.lib wxmsw31u_html.lib wxmsw31u_qa.lib wxmsw31u_ribbon.lib wxmsw31u_richtext.lib wxmsw31u_stc.lib wxmsw31u_webview.lib wxmsw31u_xrc.lib wxpng.lib wxregexu.lib winmm.lib wxscintilla.lib wxtiff.lib wxzlib.lib wxmsw31u_adv.lib wxmsw31u_media.lib wxmsw31u_propgrid.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib Ws2_32.lib urlmon.lib wininet.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

the simple example code:

Code: Select all

simple_window.h
#ifndef SIMPLE_WINDOW_H
#define SIMPLE_WINDOW_H

#define wxDEBUG_LEVEL 0

#include <wx/wx.h>

class myFrame : public wxFrame
{
public:
	myFrame(const wxString title);
private:
	void OnQuitButton(wxCommandEvent &event);
	wxDECLARE_EVENT_TABLE();
};

#endif

Code: Select all

simple_window.cpp
#include"simple_window.h"

#define ID_BUTTON_QUIT 40000

wxBEGIN_EVENT_TABLE(myFrame, wxFrame)
	EVT_BUTTON(ID_BUTTON_QUIT, myFrame::OnQuitButton)
wxEND_EVENT_TABLE()

myFrame::myFrame(const wxString title):wxFrame(NULL,wxID_ANY,title)
{
	SetWindowStyleFlag(wxFRAME_NO_TASKBAR | wxNO_BORDER);  
	wxButton* m_button1 = new wxButton(this, ID_BUTTON_QUIT, wxT("提示"), wxDefaultPosition, wxDefaultSize, 0);
}

void myFrame::OnQuitButton(wxCommandEvent &event)
{
	wxMessageBox(wxT("hoho"), wxT("Message"),wxYES|wxNO,this);
}
How to solve it? Thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: LNK2019 wxString::SubstrBufFromType

Post by doublemax »

I don't get any error when compiling your code.

But try removing the "#define wxDEBUG_LEVEL 0" line. This can only be changed when compiling the wxWidgets libraries, you can't override this in user code.

If that doesn't work, make sure that your code is compiled with the same configuration that was used when building the wxWidgets libraries.
Use the source, Luke!
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: LNK2019 wxString::SubstrBufFromType

Post by stahta01 »

I thought wxDEBUG_LEVEL could be redefined in user code; can you confirm it can not be?

Tim S.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: LNK2019 wxString::SubstrBufFromType

Post by ONEEYEMAN »

Hi,
User code should be compiled with exactly the same set of option s as the library.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: LNK2019 wxString::SubstrBufFromType

Post by PB »

Actually, the docs clearly state that wxDEBUG_LEVEL can have different values in the user application and wxWidgets, as long as its value in the application is set before including any wxWidgets headers (which the OP does).
firescript
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Nov 26, 2019 1:26 am

Re: LNK2019 wxString::SubstrBufFromType

Post by firescript »

doublemax wrote: Mon Dec 02, 2019 6:23 am I don't get any error when compiling your code.

But try removing the "#define wxDEBUG_LEVEL 0" line. This can only be changed when compiling the wxWidgets libraries, you can't override this in user code.

If that doesn't work, make sure that your code is compiled with the same configuration that was used when building the wxWidgets libraries.
If I remove #define wxDEBUG_LEVEL 0,will get another error:

Code: Select all

error LNK2019: unresolved external symbol "void __cdecl wxOnAssert(char const *,int,char const *,char const *,unsigned short const *)" (?wxOnAssert@@YAXPEBDH00PEBG@Z) referenced in function "protected: virtual class wxGDIRefData * __cdecl wxGDIImage::CloneGDIRefData(class wxGDIRefData const *)const " (?CloneGDIRefData@wxGDIImage@@MEBAPEAVwxGDIRefData@@PEBV2@@Z)
firescript
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Nov 26, 2019 1:26 am

Re: LNK2019 wxString::SubstrBufFromType

Post by firescript »

ONEEYEMAN wrote: Wed Dec 04, 2019 1:43 pm Hi,
User code should be compiled with exactly the same set of option s as the library.

Thank you.
Can you list some settings? Because I am in another environment, not pure VS, and I am not familiar with some default settings of that environment. If you can list some settings that need attention, I can try to change them in the environment and see if they can be solved. Thank you very much!

library:Use Default Setting (Unicode and Static). VS2008

About another environment: setting in Imakefile.mk file
BUILT_OBJECT_TYPE=SHARED LIBRARY
LOCAL_LDFLAGS=/LIBPATH:"F:\XXXX\wxWidgets-3.1.3\lib\vc_x64_lib"
SYS_LIBS=wxbase31u.lib wxbase31u_net.lib XXXXXXXX .....
LOCAL_CCFLAGS=/I"F:\XXXX\wxWidgets-3.1.3\include" .......
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: LNK2019 wxString::SubstrBufFromType

Post by ONEEYEMAN »

Hi,
Only you know what options you used when you compiled wxWidgets.
Did you use static/dynamic one? UNICODE or not? multilib or not? debug vs release?
Those are major ones that absolutely has to match.

On top of that there are some that defined inside setup.h or configure that also should match to the T.
Otherwise you might get an unusual behavior.

Of course there are some default settings to compile the library and then you just need to know what they are to compile your own code. But that a different story.

On top of that - the library and the user code needs the same compiler (or better put ABI-compatible compiler).
However it looks like you are not using MSVC at all when compiling your own code.Am I right?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: LNK2019 wxString::SubstrBufFromType

Post by doublemax »

Please start from scratch by building the "minimal" sample that comes with wxWidgets. That should still work out of the box with the provided project files, even with your old VS version.
Use the source, Luke!
Post Reply