Author Topic: BuildProblem: undefined reference to `wxStringBase::InitWith(...  (Read 19442 times)

Offline slamdank

  • Single posting newcomer
  • *
  • Posts: 3
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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #1 on: March 07, 2008, 07:33:46 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).
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.



Offline slamdank

  • Single posting newcomer
  • *
  • Posts: 3
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #2 on: March 10, 2008, 02:29:48 pm »
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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #3 on: March 10, 2008, 03:37:39 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.

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.

Offline slamdank

  • Single posting newcomer
  • *
  • Posts: 3
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #4 on: March 12, 2008, 12:05:12 pm »
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.

Offline clingonboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #5 on: October 16, 2013, 01:17:38 am »
I have same problem, I read very very well this post and I did ecerithing but the compiler give to me always the some error, only one but I don't know what can I do.

Code
C:/wxWidgets-2.8.12/include/wx/string.h:368: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Debug\main.o:main.cpp:(.rdata$_ZTV5MyApp[__ZTV5MyApp]+0x44): undefined reference to `wxApp::Initialize(int&, char**)'

Thanks you for your patience

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #6 on: October 16, 2013, 10:38:09 am »
Please post the FULL build log here, found in the Build log tab
greetings
« Last Edit: October 16, 2013, 10:42:07 am by BlueHazzard »

Offline clingonboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #7 on: October 17, 2013, 09:36:58 am »
I'm sorry for the mistake.
I solved the problem, I have uninstalled the library, reinstalled the library, recompiled the library and now it works well.

Thanks you.

Offline clingonboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #8 on: October 17, 2013, 08:47:34 pm »
something strange

I try to rebuild the some progject and I recive this error from the compiler:
Code

-------------- Build: Debug in secondo (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions  -g    -IC:\wxWidgets-2.8.12\include -IC:\wxWidgets-2.8.12\lib\gcc_dll\mswu  -c "D:\prove cpp\secondo\main.cpp" -o obj\Debug\main.o
In file included from C:\wxWidgets-2.8.12\include/wx/defs.h:21:0,
                 from C:\wxWidgets-2.8.12\include/wx/wx.h:15,
                 from D:\prove cpp\secondo\main.h:4,
                 from D:\prove cpp\secondo\main.cpp:1:
C:\wxWidgets-2.8.12\include/wx/platform.h:196:22: fatal error: wx/setup.h: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
 

I don't understand, yesterday It was working

Online stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #9 on: October 17, 2013, 09:22:20 pm »
Does this folder exist? "C:\wxWidgets-2.8.12\lib\gcc_dll\mswu\wx"
Does it contain setup.h? NOTE: DO NOT manually copy setup.h to this folder!!

Tim S. 
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline clingonboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #10 on: October 17, 2013, 09:41:19 pm »
there is only the folder c:/wxWidgets/lib/gcc_dll/msw and inside there is the folder /wx with inside the file setup.h

if I go manually in the folder: c:/wxWidgets-2.8.12/sample and I open some folder and try to build some example with the comad:

mingw32-make -f makegile.gcc SHARED=1 BUILD=release

it work correctly

Offline clingonboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #11 on: October 17, 2013, 10:49:23 pm »
I rename the folder
C:\wxWidgets-2.8.12\lib\gcc_dll\msw
in C:\wxWidgets-2.8.12\lib\gcc_dll\mswu

and now it works.

I don't know id is legal and correct but works, at last for this simple tutorial project.

why c::b give to the compiler the path with this name of the folder?

I don't understand why yesterday it was work, I don't change nothing

Online stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: BuildProblem: undefined reference to `wxStringBase::InitWith(...
« Reply #12 on: October 18, 2013, 12:56:00 am »
I rename the folder
C:\wxWidgets-2.8.12\lib\gcc_dll\msw
in C:\wxWidgets-2.8.12\lib\gcc_dll\mswu

and now it works.

I don't know id is legal and correct but works, at last for this simple tutorial project.

why c::b give to the compiler the path with this name of the folder?

I don't understand why yesterday it was work, I don't change nothing

Read http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef#UNICODE
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org