Author Topic: CB setup for wxWidgets / windows  (Read 9015 times)

Offline robkai

  • Single posting newcomer
  • *
  • Posts: 4
CB setup for wxWidgets / windows
« on: November 16, 2010, 07:08:54 pm »
Hope this is the right place for this question.  First time posting a question -- I'd rather have figured this out myself.

I am new to codeblocks and C++ programming, but I have hit the wall trying to setup wxWidgets with codeblocks, and unable to figure this out with the documents I've studied.  Sorry for the long question, but I believe that the answer would make a nice wiki to help users understand how to set this up.

I'm running CB 10.05, and wxWidgets 2.9.1 on Win2000.  I can successfully compile wxWidgets three different ways, using parameters to indicate compiling monolithic, dll, debug, etc.:

  1)  ../configure then make
     puts the libs and wx-config in the user defined folder; include is in $(#wx)/include

  2)  ../configure then make then make install
     puts libs, include, wx-config in /usr/local/lib (for me, c:\dev\msys\local\lib)

  3)  minGW32-make. 
     puts libs in $(#wx)/lib/gcc_dll, no wx-config, include is in $(#wx)/include



They all compile without problems.  But each of these methods results in the libs in different directories; some create a wx-config file and some do not (method 3). 

I then test my set up by trying to compile/link/run a wxSmith minimal project, and the minimal sample cpp file through CB.  I've tried setting up CB multiple ways with each compilation.  I get linker errors, such as:

  D:\Projects32\Codeblocks\test\test12\test12App.cpp|17|undefined reference to `      _imp___Z7wxEntryP11HINSTANCE__S0_Pci'|


I've spent the last couple of weeks trying to figure out how to set the compiler and linker parameters with CB; none seem to work. 

My first question is simply where CB assumes the library and header directories are located?  I assume when you set the base for $(#wx), it assumes these are in certain folders.  For instance, if I knew that the libs are assumed to be in $(#wx)/lib/gcc_dll, then I presume I would need to specify an alternate lib folder if compiling with method 1 or 2 (correct?).


Here is my current setup: The most current wxWidgets compilation uses method 3 (minGW32-make) which puts libs in $(#wx)/lib/gcc_dll; it is not monolithic, not shared, and is debug.  Since it is not compile method 1 or 2, I have not added the `wx-config --cxxflags` or `wx-config --libs` (though I've tried this with compilation methods one and two) (BTW, I assume wx-config must lie in a directory in the PATH variable).

  Global variables
   $(#wx)   =  C:\dev\wxMSW-2.9.1  (install directory for wxWidgets)
               include, lib, bin, cFlags, lFlags left blank

  CB Env variables
   PATH  includes  C:\dev\wxMSW-2.9.1\include;C:\dev\wxMSW-2.9.1\lib\gcc_lib

  Global compiler settings
    compiler flags (not sure what these do, but suggested in some docs)
      -pipe
      -mthreads
      [[if (PLATFORM == PLATFORM_MSW && (GetCompilerFactory().GetCompilerVersionString(_T("gcc")) >= _T("4.0.0"))) print(_T("-Wno-attributes")]]
   
    compiler defines (also tried setting WXUSINGDLL wxUSE_UNICODE for those builds)
      __GNUWIN32__
      __WXMSW__
      __WXDEBUG__

    linker settings/libraries (all libs in the gcc_dll directory) such as
      C:\dev\wxMSW-2.9.1\lib\gcc_lib\libwxzlibd.a
      C:\dev\wxMSW-2.9.1\lib\gcc_lib\libwxbase29d_net.a
      etc . . .

    linker settings / other options
      -mthreads

    Search directories / compiler
      $(#wx)\include   (have also tried $(#wx.include))
      $(#wx)\lib\gcc_dll\mswd
      $(#wx)\contrib\include

    search directories / linker
      $(#wx)\lib\gcc_lib

    search directories / resource compiler
      $(#wx)\lib\gcc_lib
      $(#wx)\include
      $(#wx)\lib\gcc_lib\mswd

     
What am I missing?  This is driving me to alcohol so any help is appreciated. 
Thanks.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
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 robkai

  • Single posting newcomer
  • *
  • Posts: 4
Re: CB setup for wxWidgets / windows
« Reply #2 on: November 19, 2010, 08:26:57 pm »
I've been through every aspect of http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef, doesn't help.

I can build wxWidgets.  Codeblocks working, but problems linking the most basic wxSmith app.  it compiles ok, just doesn't seem to link properly (which I assume is an incorrect linker setup), following errors.  What simple think am I missing?


||=== test12, Debug ===|
||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|
obj\Debug\test12App.o:test12App.cpp:(.rdata$_ZTV9test12App[vtable for test12App]+0x5c)||undefined reference to `wxApp::Initialize(int&, wchar_t**)'|
obj\Debug\test12App.o:test12App.cpp:(.rdata$_ZTV9test12App[vtable for test12App]+0xc8)||undefined reference to `wxAppConsoleBase::OnAssertFailure(wchar_t const*, int, wchar_t const*, wchar_t const*, wchar_t const*)'|
obj\Debug\test12App.o:test12App.cpp:(.rdata$_ZTV9test12App[vtable for test12App]+0xcc)||undefined reference to `wxAppConsoleBase::OnAssert(wchar_t const*, int, wchar_t const*, wchar_t const*)'|
)]+0x2c)||undefined reference to `wxString::ConvertStr(char const*, unsigned int, wxMBConv const&)'|
||Info: resolving vtable for __cxxabiv1::__si_class_type_info by linking to __imp___ZTVN10__cxxabiv120__si_class_type_infoE |
||Info: resolving vtable for __cxxabiv1::__vmi_class_type_info by linking to __imp___ZTVN10__cxxabiv121__vmi_class_type_infoE |
||Info: resolving vtable for __cxxabiv1::__class_type_info by linking to __imp___ZTVN10__cxxabiv117__class_type_infoE |
||Info: resolving std::cerr  by linking to __imp___ZSt4cerr |
||Info: resolving typeinfo for std::basic_streambuf<char, std::char_traits<char> > by linking to __imp___ZTISt15basic_streambufIcSt11char_traitsIcEE |
||=== Build finished: 4 errors, 1 warnings ===|


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: CB setup for wxWidgets / windows
« Reply #3 on: November 19, 2010, 09:01:17 pm »
Turn on Full Compiler Logging

http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Do a rebuild of the wxWidgets project and post the build log.
I should be able to spot what is wrong.

This is the method normally used under windows

  3)  minGW32-make.  
     puts libs in $(#wx)/lib/gcc_dll, no wx-config, include is in $(#wx)/include


Tim S.
« Last Edit: November 19, 2010, 09:03:00 pm by stahta01 »
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: CB setup for wxWidgets / windows
« Reply #4 on: November 20, 2010, 12:11:27 am »
Full Build log of wxWidgets project.

My wxWidgets Base is H:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ

Tim S.

Code
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wno-attributes -Wall  -g  -Wmissing-include-dirs   -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\include -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\contrib\include -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\lib\gcc_dll\mswu -IC:\GreenApps\MinGW_CodeBlocks10_05\include -IH:\SourceCode\CBProjects\TestProjects\testwx29 -IH:\SourceCode\CBProjects\TestProjects\testwx29 -c H:\SourceCode\CBProjects\TestProjects\testwx29\testwx29App.cpp -o obj\Debug\testwx29App.o
cc1plus.exe: warning: H:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\contrib\include: No such file or directory
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wno-attributes -Wall  -g  -Wmissing-include-dirs   -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\include -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\contrib\include -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\lib\gcc_dll\mswu -IC:\GreenApps\MinGW_CodeBlocks10_05\include -IH:\SourceCode\CBProjects\TestProjects\testwx29 -IH:\SourceCode\CBProjects\TestProjects\testwx29 -c H:\SourceCode\CBProjects\TestProjects\testwx29\testwx29Main.cpp -o obj\Debug\testwx29Main.o
cc1plus.exe: warning: H:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\contrib\include: No such file or directory
windres.exe -i H:\SOURCE~1\CBPROJ~1\TESTPR~1\testwx29\resource.rc -J rc -o obj\Debug\resource.res -O coff -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\include -IH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\lib\gcc_dll\mswu -IH:\SOURCE~1\CBPROJ~1\TESTPR~1\testwx29 -IH:\SourceCode\CBProjects\TestProjects\testwx29
mingw32-g++.exe -LH:\SourceCode\OpenSourceCode\Libs\GUI\wxWidgets\wxWidgets-2.9.1-SJLJ\lib\gcc_dll  -o bin\Debug\testwx29.exe obj\Debug\testwx29App.o obj\Debug\testwx29Main.o  obj\Debug\resource.res  -mthreads  -lwxmsw29u  -mwindows
Output size is 771.77 KB
Process terminated with status 0 (0 minutes, 14 seconds)
0 errors, 2 warnings
 
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 robkai

  • Single posting newcomer
  • *
  • Posts: 4
Re: CB setup for wxWidgets / windows
« Reply #5 on: November 25, 2010, 08:21:14 pm »
Tim,

I really appreciate you taking the time to help. Full compiler logging was a great tip.  Tried playing around to see what setting change what options in the compiler but I think I'm getting more lost.  Here is what the compiler logging shows, and here are my settings in CB.  I was trying to make the settings global so they would take effect for any wxwidgets project, but maybe I am screwing things up.  What am I missing?

(By the way, I was expecting to see paths listed on the 'search directories' show up as -I flags)

Here's the build log.  (test12 is a minimal wxSmith project):

-------------- Build: Debug in test12 ---------------

mingw32-g++.exe -LC:\dev\wxMSW-2.9.1\lib\gcc_lib -LC:\dev\wxMSW-2.9.1\lib\gcc_lib -LC:\dev\wxMSW-2.9.1\lib\gcc_lib\mswd  -o bin\Debug\test12.exe obj\Debug\test12App.o obj\Debug\test12Main.o  obj\Debug\resource.res  -mthreads -mthreads  -lwxmsw29d "C:\Program Files\MySQL\MySQL Server 5.1\lib\opt\libmysqlclient.a" C:\dev\wxMSW-2.9.1\lib\gcc_lib\libwxmsw29d.a  -mwindows


And here are my settings, starting with global CB settings, and followed by compiler settings:


CB environmental variables:
  PATH = C:\dev\wxMSW-2.9.1\include;C:\dev\wxMSW-2.9.1\lib\gcc_lib;c:\dev\minGW\bin;c:\dev\minGW;c:\Program Files\CodeBlocks\share\codeblocks\plugins;C:\dev\MSys\local\lib\wx2.9\bin;%PATH%

wx variable:
  C:\dev\wxMSW-2.9.1


***********************************
Global compiler setting:
 
 Compiler settings - other options:
     -pipe
     [[if (PLATFORM == PLATFORM_MSW && (GetCompilerFactory().GetCompilerVersionString(_T("gcc")) >=
 _T("4.0.0"))) print(_T("-Wno-attributes")]]

 Compiler settings - #defines: (wxWidgets compiled monolithic, static, no unicode, debug)
     __GNUWIN32__
     __WXMSW__
     __WXDEBUG__

 Linker settings - link libraries:
     C:\Program Files\MySQL\MySQL Server 5.1\lib\opt\libmysqlclient.a
     C:\dev\wxMSW-2.9.1\lib\gcc_lib\libwxmsw29d.a

 Linker settings - other linker options:
     -mthreads

 Search directories - compiler
     C:\Program Files\MySQL\MySQL Server 5.1\include
     $(#wx)\include
     $(#wx)\lib\gcc_lib\mswd
     $(#wx)\contrib\include
     $(#wx)\lib\gcc_lib

 Search directories - linker
     $(#wx)\lib\gcc_lib
     $(#wx)\include
     $(#wx)\lib\gcc_lib\mswd

 Search directories - compiler
     $(#wx)\lib\gcc_lib
     $(#wx)\lib\gcc_lib\mswd

 Search directories - resource compile
     C:\Program Files\MySQL\MySQL Server 5.1\include
     $(#wx)\include
     $(#wx)\lib\gcc_lib\mswd
     $(#wx)\contrib\include
     $(#wx)\lib\gcc_lib
 
  Toolchain executables
     installation directory: c:\dev\MinGW

***************************

Project build options (project name is test12):

  Compiler settings - other options (under test12)
     -pipe
     -mthreads
     [[if (PLATFORM == PLATFORM_MSW && (GetCompilerFactory().GetCompilerVersionString(_T("gcc")) >=_T("4.0.0"))) print(_T("-Wno-attributes"));]]

  Compiler settings - other options (under debug)
     <nothing>

  Compiler settings - #defines (under test12)
     __GNUWIN32__
     __WXMSW__
  Compiler settings - #defines (under Debug)
     __WXDEBUG__

  Linker settings - link libraries (under test12)
     <nothing>
  Linker settings - link libraries (under Debug)
     libwxmsw29d.a
  Linker settings - other linker options (under test12)
     -mthreads
  Linker settings - other linker options (under Debug)
     <nothing>

  Search directories - compiler (under test12)
     $(#wx)\include
     $(#wx)\contrib\include
 
 Search directories - compiler (under Debug)
     $(#wx)\lib\gcc_lib\mswd

  Search directories - linker (under test12)
     <nothing>

  Search directories - linker (under Debug)
     $(#wx)\lib\gcc_lib

  Search directories - resource compiler (under test12)
     $(#wx)\include

  Search directories - resource compiler (under Debug)
     $(#wx)\lib\gcc_lib\mswd





Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: CB setup for wxWidgets / windows
« Reply #6 on: November 25, 2010, 08:49:04 pm »
What options did you use with minGW32-make build of wxWidgets?

And, what type build of wxWidgets do you want to use?
Release/debug, ANSI/Unicode, Monolithic/MultiLib, SHARED(DLL)/static Library

Tim S.
« Last Edit: November 25, 2010, 08:52:40 pm by stahta01 »
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: CB setup for wxWidgets / windows
« Reply #7 on: November 25, 2010, 08:54:08 pm »
Why are you linking to the below library?
Code
C:\Program Files\MySQL\MySQL Server 5.1\lib\opt\libmysqlclient.a

Start a new Project using the CB wxWidgets wizard to get the right settings.
Or find someone else to help.

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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CB setup for wxWidgets / windows
« Reply #8 on: November 25, 2010, 09:54:03 pm »
It's in general not a good idea to use such special settings (mysq and wxwidgets) as global compiler settings, if you do not make a copy of the compiler (e.g. "GCC for wxWidgets"), because you apply settings to projects and files even if you do not need them.
We had several posts about compiler issue, just because the user has made global settings and forgot to remove them.

Offline robkai

  • Single posting newcomer
  • *
  • Posts: 4
Re: CB setup for wxWidgets / windows
« Reply #9 on: November 25, 2010, 11:43:03 pm »
Thanks.  I've tried compiling wxWidgets multiple ways and different versions, but this one was

 wxWidgets compiled monolithic, static, no unicode, debug

I had written a medical billing/records software 14 years ago using visual basic and SQLServer, and I am fed up with having to continually update Windows software every 3-4 years.  It is prohibitively expensive for a small company to do so.  So I decided to finally bite the bullet and re-write the whole project from scratch with C++ and open software, MySQL/Codeblocks/wxWidgets to start.  (I had played with Netbeans/java as well, but the startup of the virtual machine seems to slow things down and C++ seemed cleaner).

I started with porting the data validation routines and basic database connection routines as a way to start learning the new language, so I just left the link in for MySQL library when I started working with wxWidgets.

I have one windows machine and one linux machine to get benefit of cross compiling.

Funny thing is, I had it working (now I realize was just dumb luck not any innate knowledge), but realized I needed the richtextctrl which didn't seem to be in the wxWidgets 2.8 library I built.  When I compiled the 2.9 library I must have changed some settings.

You've been a big help, though.  It sounds like I'm getting some conflicts between the global settings and project specific settings.  I'm going to clear out everything and start from scratch and see if I can work it out.

Mahalo (live in hawaii) and have a good thanksgiving.

Rob.