User forums > Using Code::Blocks

BuildProblem: undefined reference to `wxStringBase::InitWith(...

(1/3) > >>

slamdank:
Hello,

Purpose: to build and run a simple wxWidgets-based "HelloWorld"-Application from (http://www.wxwidgets.org/docs/tutorials/hello.htm).

(1) downloaded Code::Blocks (v8.02) with MinGW compiler (v3.4.5) as binaries; installed it.

(2) Created a new WxWidgets-Project under Code::Blocks.

(3) downloaded wxWidgets v2.8.7; build libraries as described by the "Nightly_Cookbook" (http://wiki.codeblocks.org/index.php?title=Nightly_Cookbook#wxWidgets)
 mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 clean
 mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1

(4) Added all (*.a) built libraries from C:\wxWidgets-2_8_7\lib\gcc_dll to the C::B->Project->BuildOptions->LinkerSettings->Link Libraries.
Added wxmsw28u_gcc_custom.dll file to the Project (don't know whether I really need it or not).

(5) When I try to build my project the build ist stopped with following message: 
...
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.C:\wxWidgets-2_8_7\TE_Projects\TestWidgetsApp_HelloWorld\Release\obj\TestWidgetsApp_HelloWorldMain.o: In function `_ZN30TestWidgetsApp_HelloWorldFrameC2ERK8wxStringRK7wxPointRK6wxSize':
C:/wxWidgets-2_8_7/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
C:/wxWidgets-2_8_7/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
C:/wxWidgets-2_8_7/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
C:/wxWidgets-2_8_7/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
C:/wxWidgets-2_8_7/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
C:\wxWidgets-2_8_7\TE_Projects\TestWidgetsApp_HelloWorld\Release\obj\TestWidgetsApp_HelloWorldMain.o:C:/wxWidgets-2_8_7/include/wx/string.h:368: more undefined references to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)' follow
C:\wxWidgets-2_8_7\TE_Projects\TestWidgetsApp_HelloWorld\Release\obj\TestWidgetsApp_HelloWorldApp.o: In function `_ZN20wxThreadHelperThreadD1Ev':
C:/wxWidgets-2_8_7/include/wx/string.h:(.rdata$_ZTV28TestWidgetsApp_HelloWorldApp[vtable for TestWidgetsApp_HelloWorldApp]+0x44): undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 8 seconds)
7 errors, 1 warnings
 
Any idea about undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'?

regards

Jenna:

--- Quote from: slamdank on March 07, 2008, 07:05:34 pm ---(4) Added all (*.a) built libraries from C:\wxWidgets-2_8_7\lib\gcc_dll to the C::B->Project->BuildOptions->LinkerSettings->Link Libraries.
Added wxmsw28u_gcc_custom.dll file to the Project (don't know whether I really need it or not).

--- End quote ---
You don't need this.

If you create a wxWidgets project with the wizard, you are asked where your wxWidgets-installation is.
You can either leave everything as it is there (in case you have set the global variable "wx" correctly) or tell the wizard the root-directory of the wxWidgets-sources (in my case its "c:\wxWidgets-2.8.7"), then tell the wizardthat you use the wxWidgets dll, it's a monolithic build and to enable unicode in the appropriate window.

That should be enough to compile the test project.

P.S.
You can set "wx" in "Settings -> Global variables...". In the line with the deropdownlist for the current variable click the "New" button, if the variable does not exist.
Only set the base to your wxWidgets root dir (as mentioned above) and leave all the other fields empty.


slamdank:
thank You for proposals,
but it seems to be not enough to build an application ;-)

a new problem is as follows:
wx/wx.h: No such file or directory

FYI:
I added to "Search directories" both for Complier and Linker 'C:\wxWidgets-2_8_7\include\wx' as directory
where the 'wx.h' file can be found.

Any idea?

Jenna:

--- Quote from: slamdank on March 10, 2008, 02:29:48 pm ---a new problem is as follows:
wx/wx.h: No such file or directory

FYI:
I added to "Search directories" both for Complier and Linker 'C:\wxWidgets-2_8_7\include\wx' as directory
where the 'wx.h' file can be found.

--- End quote ---

Either you did not use the wizard, or you changed something manually.

The search-dir you added is wrong !!
The compiler seraches for "wx/wx.h". With your path "wx.h" is looked for in "C:\wxWidgets-2_8_7\include\wx\wx", what not exists.

The correct path "C:\wxWidgets-2_8_7\include" is already in "Search directories". Not in the "Build taregt" specific, but in the "Search directories" for the whole project.

But only if you have used the wxWidgets-wizard and told it the wxWidgets base-dir correctly.

If it still does not work, you must have messed up some other things.

It would perhaps be the best way to first set the "wx" global-var correctly (only the base as posted before) and then create a new project.

And don't forget to check "Use wxWidgets dll", "wxWidgets is built as monolithic library" and "Enable unicode" unless you know exactly what you do.

slamdank:
Thanks a lot for your hints, it finally works.

The really best way to get it worked, to tell the c::b.wizard all parameters it needs while buildup a new (wxWidgets)-Project.

Navigation

[0] Message Index

[#] Next page

Go to full version