Compile wxWidgets and boost in windows and add them to the codeblocks path (Visual C ++ 2008/mingw32)
Compile wxWidgets
1, to the official website to download the source package (MSW), install to X: \ wxwidgets-x.x.xxx
2. Install visual c ++ express 2008 or install mingw32 (we recommend that you download http://tdm-gcc.tdragon.net/to automatically update the environment variable)
3. Use the console provided by VC (the system is not available, and the system console encounters the "0xc0000135" error because environment variables are not configured) to compile and compile the two versions, both the release and DEBUG Versions of Unicode use dynamic libraries (for cross-platform convenience)
The compilation command is as follows:
1), enter the source directory Cd x: \ wxwidgets-x.x.xxx \ build \ MSW
2) Start Compilation
For
Nmake-F makefile. VC Unicode = 1 build = release (static release default shared = 0)
Nmake-F makefile. VC Unicode = 1 build = debug (static debugging Version)
Nmake-F makefile. VC shared = 1 Unicode = 1 build = release (Dynamic Release)
Nmake-F makefile. VC shared = 1 Unicode = 1 build = debug (Dynamic Release)
For mingw32
Mingw32-make-F makefile. GCC Unicode = 1 build = release
Mingw32-make-F makefile. GCC Unicode = 1 build = debug
Mingw32-make-F makefile. GCC shared = 1 Unicode = 1 build = release
Mingw32-make-F makefile. GCC shared = 1 Unicode = 1 build = debug
Compile boost
1. download the latest source code package and boost-jam-* -ntx86.zip from the official website and decompress it to a Temporary Folder X: \ TMP \ boost_000045_0.
2. Use the console provided by VC to Compile two versions of debug and release.
The compilation command is as follows:
1) Go to the temporary source code directory Cd x: \ TMP \ boost_1_45_0
2) query the module bjam -- show-libraries to be compiled
3) Start compilation. (cancel compilation of the wave, Mpi, and Python modules. Because icu4c is not installed, RegEx cannot support Unicode. The prefix option specifies the boost installation path) static Link Library
Bjam install toolset = msvc-9.0 -- prefix = "C: \ boost_rj45_0" Debug -- without-wave -- without-MPI -- without-Python -- without-RegEx link = static runtime-link = static
Bjam install toolset = msvc-9.0 -- prefix = "C: \ boost_000045_0" release -- without-wave -- without-MPI -- without-Python -- without-RegEx link = static runtime-link = static
Bjam install toolset = GCC -- prefix = "C: \ boost_rj45_0" Debug -- without-wave -- without-MPI -- without-Python -- without-RegEx link = static runtime-link = static
Bjam install toolset = GCC -- prefix = "C: \ boost_000045_0" release -- without-wave -- without-MPI -- without-Python -- without-RegEx link = static runtime-link = static
Dynamic Link Library
Bjam install toolset = msvc-9.0 -- prefix = "C: \ boost_rj45_0" Debug -- without-wave -- without-MPI -- without-Python -- without-RegEx link = shared runtime-link = shared
Bjam install toolset = msvc-9.0 -- prefix = "C: \ boost_000045_0" release -- without-wave -- without-MPI -- without-Python -- without-RegEx link = shared runtime-link = shared
Bjam install toolset = GCC -- prefix = "C: \ boost_rj45_0" Debug -- without-wave -- without-MPI -- without-Python -- without-RegEx link = shared runtime-link = shared
Bjam install toolset = GCC -- prefix = "C: \ boost_000045_0" release -- without-wave -- without-MPI -- without-Python -- without-RegEx link = shared runtime-link = shared
If it is fully compiled, the command is as follows:
Bjam install -- toolset = msvc-9.0 -- prefix = "C: \ boost_000045_0" Debug -- Build-type = complete
Bjam install -- toolset = msvc-9.0 -- prefix = "C: \ boost_000045_0" release -- Build-type = complete
Add to codeblocks
WxWidgets
Configure wxWidgets for the current variable and create the variable WX
Add the base path c: \ wxwidgets-x.x.xxx
Add include c: \ wxwidgets-x.x.xxx \ include
Add lib c: \ wxwidgets-x.x.xxx \ Lib
Boost
Add base path c: \ boost_1_45_0
Add include c: \ boost_1_45_0 \ include \ boost-1_45
Add lib c: \ boost_000045_0 \ Lib
If there is a problem with setting global variables in boost, you must add them to the search path of compiler and linker.
Settings -- compiler and debugger settings -- search for folders
Compiler add c: \ boost_1_45_0 \ include \ boost-1_45
Add c: \ boost_rj45_0 \ Lib to linker
When using boost: thread library, the following error may occur (gcc4.4 + boost1.40 in Linux)
| === Testthread, release === |
OBJ/release/Main. o | in function 'main': |
Main. cpp | undefined reference to 'boost: thread: Join () '|
Main. cpp | undefined reference to 'boost: thread: Join () '|
Main. cpp | undefined reference to 'boost: thread ::~ Thread () '|
Main. cpp | undefined reference to 'boost: thread ::~ Thread () '|
Main. cpp | undefined reference to 'boost: thread ::~ Thread () '|
Main. cpp | undefined reference to 'boost: thread ::~ Thread () '|
OBJ/release/Main. o | in function 'boost: detail: thread_data <void (*) ()> ::~ Thread_data () ': |
::~ Thread_data ()] + 0x14) | undefined reference to 'boost: detail: thread_data_base ::~ Thread_data_base () '|
OBJ/release/Main. o | in function 'boost: detail: thread_data <void (*) ()> ::~ Thread_data () ': |
::~ Thread_data ()] + 0x11) | undefined reference to 'boost: detail: thread_data_base ::~ Thread_data_base () '|
OBJ/release/main. o | in function 'boost: thread <void (*) ()> (void (*) (), boost: disable_if <boost :: is_convertible <void (* &) (), boost: detail: thread_move_t <void (*) () >>, boost: thread: dummy * >:: type) ': |
: Type)] + 0x4b) | undefined reference to 'vtable for Boost: detail: thread_data_base '|
: Type)] + 0x166) | undefined reference to 'boost: thread: start_thread () '|
: Type)] + 0x18a) | undefined reference to 'boost: thread_resource_error () '|
: Type)] + 0x192) | undefined reference to 'boost: thread_resource_error ::~ Thread_resource_error () '|
: Type)] + 0x19a) | undefined reference to 'typeinfo for Boost: thread_resource_error '|
: Type)] + 0x1ba) | undefined reference to 'boost: thread_resource_error () '|
: Type)] + 0x1c2) | undefined reference to 'boost: thread_resource_error ::~ Thread_resource_error () '|
: Type)] + 0x1ca) | undefined reference to 'typeinfo for Boost: thread_resource_error '|
: Type)] + 0x1eb) | undefined reference to 'boost: thread_resource_error () '|
: Type)] + 0x1f6) | undefined reference to 'boost: thread_resource_error ::~ Thread_resource_error () '|
: Type)] + 0x1fe) | undefined reference to 'typeinfo for Boost: thread_resource_error '|
: Type)] + 0x223) | undefined reference to 'boost: thread_resource_error () '|
: Type)] + 0x22e) | undefined reference to 'boost: thread_resource_error ::~ Thread_resource_error () '|
: Type)] + 0x236) | undefined reference to 'typeinfo for Boost: thread_resource_error '|
: Type)] + 0x25b) | undefined reference to 'boost: thread_resource_error () '|
: Type)] + 0x266) | undefined reference to 'boost: thread_resource_error ::~ Thread_resource_error () '|
: Type)] + 0x26e) | undefined reference to 'typeinfo for Boost: thread_resource_error '|
] + 0x8) | undefined reference to 'typeinfo for Boost: detail: thread_data_base '|
| === Build finished: 26 errors, 0 warnings (0 minutes, 3 seconds) ==|
Or the following error (Windows gcc4.5 + boost1.45)
C: \ boost_000045 \ include \ boost-1_45 \ boost \ thread \ Win32 \ thread_heap_alloc.hpp | 59 | warning: inline function 'void * boost: detail: allocate_raw_heap_memory (unsigned INT) 'clared as dllimport: attribute ignored |
C: \ boost_000045 \ include \ boost-1_45 \ boost \ thread \ Win32 \ thread_heap_alloc.hpp | 69 | warning: inline function 'void boost: detail: free_raw_heap_memory (void *) 'clared as dllimport: attribute ignored |
OBJ \ debug \ main. O: Main. cpp :(. Text $ _ zn5boost12thread_groupd1ev [boost: thread_group ::~ Thread_group ()] + 0x77) | undefined reference to '_ imp ___ zn5boost6threadd1ev' |
OBJ \ debug \ main. o: Main. CPP :(. text $ _ zn5boost12thread_group8join_allev[ boost: thread_group: join_all ()] + 0x87) | undefined reference to '_ imp ___ zn5boost6thread4joinev' |
: Type)] + 0x58) | undefined reference to '_ imp ___ zn5boost6thread12start_threadev' |
: Type)] + 0x55) | undefined reference to '_ imp ___ zn5boost6thread12start_threadev' |
::~ Auto_ptr ()] + 0x14) | undefined reference to '_ imp ___ zn5boost6threadd1ev' |
| === Build finished: 5 errors, 2 warnings (0 minutes, 5 seconds) ==|
The above error is because the static Link Library of the thread is not imported. The solution is as follows:
If boost: thread is used, the link = static runtime-link = static option is used to compile the boost library when static links are used.
For Ubuntu, you need to add-lboost_thread to linker settings --> Other Linker Options in build options of the project.
For Windows, you need to add boost_000045 \ Lib \ libboost_thread-mgw45-mt-1_45.a to linker settings -- Link Libraries in the build options of the project (note that debug and release need the library file corresponding to the field ), and modify the header file (boost_000045 \ include \ boost_000045 \ boost \ thread \ detail \ config. in HPP), add a macro at the end | defined (mingw32), and compiler in build options
# Defines in settings add mingw32 or add this macro to global settings once and for all (settings --> compiler and debugger --> compiler settings --> # Add the red mingw32 to defines)
When using a dynamic link library, that is, when compiling the boost library, use the option link = shared runtime-link = shared
For Windows, you need to add boost_000045 \ Lib \ libboost_thread-mgw45-mt-1_45-dll.a to linker settings -- Link Libraries in the build options of the project (note that debug and release need the library file corresponding to the field ), and copy the DLL file to the root directory of the compiled executable program.