]>
Commit | Line | Data |
---|---|---|
1 | Installing wxWidgets for Windows | |
2 | ----------------------------------------------------------- | |
3 | ||
4 | This is wxWidgets for Microsoft Windows 9x/ME, Windows NT | |
5 | and later (2000, XP, Vista, 7, etc) and Windows CE. | |
6 | ||
7 | These installation notes can be found in docs/msw/install.txt | |
8 | in your wxWidgets distribution. | |
9 | ||
10 | IMPORTANT NOTE: If you experience problems installing, please | |
11 | re-read these instructions and other related files (changes.txt, | |
12 | readme.txt, FAQ) carefully before posting to wx-users list. | |
13 | ||
14 | If you are sure that you found a bug, please report it at | |
15 | wxWidgets Trac: | |
16 | ||
17 | http://trac.wxwidgets.org/newticket | |
18 | ||
19 | Please notice that often trying to correct the bug yourself is the | |
20 | quickest way to fix it. Even if you fail to do it, you may | |
21 | discover valuable information allowing us to fix it while doing | |
22 | it. We also give much higher priority to bug reports with patches | |
23 | fixing the problems so this ensures that your report will be | |
24 | addressed sooner. | |
25 | ||
26 | ||
27 | Table of Contents: | |
28 | - Installation | |
29 | - Building wxWidgets | |
30 | - Configuring the Build | |
31 | - Building Applications Using wxWidgets | |
32 | ||
33 | ||
34 | Installation | |
35 | ============ | |
36 | ||
37 | Please simply uncompress the .zip file manually into any directory. | |
38 | However we advise avoiding using directories with spaces in their | |
39 | names (notably "C:\Program Files") as this risks creating problems | |
40 | with makefiles and other command-line tools. | |
41 | ||
42 | ||
43 | In the majority of cases, you don't need to change the default | |
44 | library build configuration. If you wish to change some of the build | |
45 | options you need to edit the include/wx/msw/setup.h file enabling or | |
46 | disabling the features you would like to compile wxWidgets with[out]. | |
47 | ||
48 | NB: If you checked your sources from version control repository and | |
49 | didn't obtain them from a release file, the file above doesn't | |
50 | exist and you will need to copy include/wx/msw/setup0.h to | |
51 | include/wx/msw/setup.h. | |
52 | ||
53 | Notice that this file is later copied into a directory under lib for | |
54 | each of the build configurations which allows to have different | |
55 | build options for different configurations too. | |
56 | ||
57 | See "Configuring the Build" section for more information. | |
58 | ||
59 | ||
60 | Building wxWidgets | |
61 | ================== | |
62 | ||
63 | The following sections explain how to compile wxWidgets with each supported | |
64 | compiler, see the "Building Applications" section about the instructions for | |
65 | building your application using wxWidgets. | |
66 | ||
67 | Search for one of Microsoft/Borland/Watcom/Symantec/Metrowerks/Cygwin/Mingw32 | |
68 | to quickly locate the instructions for your compiler. Notice that the primary | |
69 | compilers for wxWidgets under MSW are Microsoft Visual C++ and GNU g++, other | |
70 | compilers are more rarely tested and might not work so please consider using | |
71 | one of these two if possible. | |
72 | ||
73 | All makefiles and project are located in build\msw directory. | |
74 | ||
75 | Where Compiled Files are Stored | |
76 | ------------------------------- | |
77 | ||
78 | After successful compilation you'll find the libraries in a subdirectory | |
79 | of lib directory named after the compiler and DLL/static settings. | |
80 | A couple of examples: | |
81 | ||
82 | lib\vc_lib VC++ compiled static libraries | |
83 | lib\vc_dll VC++ DLLs | |
84 | lib\bcc_lib Static libraries for Borland C++ | |
85 | lib\wat_dll Watcom C++ DLLs | |
86 | ||
87 | Names of compiled wxWidgets libraries follow this scheme: libraries that don't | |
88 | depend on GUI components begin with "wxbase" followed by a version number and, | |
89 | optionally, letters indicating Unicode compilation ('u') and a debug build ('d'). | |
90 | The last component is the name of the wxWidgets component (unless you build the | |
91 | library as single monolithic library; look for "Configuring the Build" below). | |
92 | This is a typical set of release ANSI build libraries (release versions on | |
93 | left, debug on right side): | |
94 | ||
95 | wxbase29.lib wxbase29d.lib | |
96 | wxbase29_net.lib wxbase29d_net.lib | |
97 | wxbase29_xml.lib wxbase29d_xml.lib | |
98 | wxmsw29_core.lib wxmsw29d_core.lib | |
99 | wxmsw29_html.lib wxmsw29d_html.lib | |
100 | wxmsw29_adv.lib wxmsw29d_adv.lib | |
101 | ||
102 | Their Unicode debug counterparts in wxUniversal build would be | |
103 | ||
104 | wxbase29ud.lib | |
105 | wxbase29ud_net.lib | |
106 | wxbase29ud_xml.lib (notice these libs are same for wxUniv and wxMSW) | |
107 | wxmswuniv29ud_core.lib | |
108 | wxmswuniv29ud_html.lib | |
109 | wxmswuniv29ud_adv.lib | |
110 | ||
111 | These directories also contain a subdirectory with the wx/setup.h header. This | |
112 | subdirectory is named after the port, Unicode, wxUniv and debug settings and | |
113 | you must add it to the include paths when compiling your application. Some | |
114 | examples: | |
115 | ||
116 | lib\vc_lib\msw\wx\setup.h VC++ static, wxMSW | |
117 | lib\vc_lib\mswud\wx\setup.h VC++ static, wxMSW, Unicode, debug | |
118 | lib\vc_lib\mswunivd\wx\setup.h VC++ static, wxUniversal, debug | |
119 | ||
120 | Below are compiler specific notes followed by customizing instructions that | |
121 | apply to all compilers (search for "Configuring the Build"). | |
122 | ||
123 | Microsoft Visual C++ Compilation | |
124 | ---------------------------------------------------------------- | |
125 | ||
126 | You may wish to visit http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide | |
127 | for a more informal and detailed description of the process summarized below. | |
128 | ||
129 | Please note that the VC++ 6.0 project files will work for VC++ .NET as well. | |
130 | ||
131 | VC++ 5.0 can also be used, providing Service Pack 3 is applied. Without it | |
132 | you will have trouble with internal compiler errors. It is available for | |
133 | download at: ftp://ftp.microsoft.com/developr/visualstudio/sp3/full. | |
134 | ||
135 | Using project files (VC++ 6 and later): | |
136 | ||
137 | 1. Unarchive wxWidgets-x.y.z-vc.zip, the VC++ 6 project | |
138 | makefiles (already included in wxMSW-x.y.z.zip and the setup version). | |
139 | 2. Open build\msw\wx.dsw, which has configurations for static | |
140 | compilation or DLL compilation, and each of these available in | |
141 | Unicode/ANSI, Debug/Release and wxUniversal or native variations. | |
142 | Normally you'll use a static linking ANSI configuration. | |
143 | Choose the Win32 Debug or Win32 Release configuration (or any other that | |
144 | suits your needs) and use Batch Build to compile _all_ projects. If you | |
145 | know you won't need some of the libraries (e.g. the HTML part), you don't have | |
146 | to compile it. It will also produce similar variations on jpeg.lib, | |
147 | png.lib, tiff.lib, zlib.lib, and regex.lib. | |
148 | ||
149 | If you want to build DLL configurations in wx.dsw project you unfortunately | |
150 | need to build them in the proper order (jpeg, png, tiff, zlib, regex, expat, | |
151 | base, net, odbc, core, gl, html, media, qa, adv, dbgrid, xrc, aui, richtext, | |
152 | propgrid) manually because VC6 doesn't always respect the correct build order. | |
153 | ||
154 | Alternatively, use the special wx_dll.dsw project which adds the | |
155 | dependencies to force the correct order (but, because of this, doesn't work | |
156 | for the static libraries) or simply redo the build several times until all | |
157 | DLLs are linked correctly. | |
158 | 3. Open a sample project file, choose a configuration such as | |
159 | Win32 Debug using Build | Set Active Configuration..., and compile. | |
160 | The project files don't use precompiled headers, to save disk | |
161 | space, but you can switch PCH compiling on for greater speed. | |
162 | NOTE: you may also use samples/samples.dsw to access all | |
163 | sample projects without opening each workspace individually. | |
164 | You can use the Batch Build facility to make several samples | |
165 | at a time. | |
166 | ||
167 | Using makefiles: | |
168 | ||
169 | 1. Change directory to build\msw. Type: | |
170 | ||
171 | 'nmake -f makefile.vc' | |
172 | ||
173 | to make the wxWidgets core library as release DLL. | |
174 | See "Configuring the Build" for instruction how to build debug or static | |
175 | libraries. | |
176 | ||
177 | 2. Change directory to samples and type 'nmake -f makefile.vc' | |
178 | to make all the samples. You can also make them individually. | |
179 | ||
180 | Makefile notes: | |
181 | ||
182 | Use the 'clean' target to clean all objects, libraries and | |
183 | executables. | |
184 | ||
185 | Note (1): if you wish to use templates, please edit | |
186 | include\wx\msw\setup.h and set wxUSE_DEBUG_NEW_ALWAYS to 0. | |
187 | Without this, the redefinition of 'new' will cause problems in | |
188 | the headers. Alternatively, #undef new before including template headers. | |
189 | You will also need to set wxUSE_IOSTREAMH to 0 if you will be | |
190 | using templates, to avoid the non-template stream files being included | |
191 | within wxWidgets. | |
192 | ||
193 | Note (2): libraries and applications generated with makefiles and | |
194 | project files are now (hopefully) compatible where static libraries | |
195 | are concerned, but please exercise caution nevertheless and if | |
196 | possible, use one method or the other. | |
197 | ||
198 | Note (3): some crash problems can be due to inconsistent compiler | |
199 | options. If strange/weird/impossible things start to happen please | |
200 | check (dumping IDE project file as makefile and doing text comparison | |
201 | if necessary) that the project settings, especially the list of defined | |
202 | symbols, struct packing, etc. are exactly the same for all items in | |
203 | the project. After this, delete everything (including PCH) and recompile. | |
204 | ||
205 | Note (4): to create your own IDE files, copy .dsp and .dsw | |
206 | files from an existing wxWidgets sample and adapt them, or | |
207 | visit http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide. | |
208 | ||
209 | Microsoft Visual C++ Compilation for 64-bit Windows | |
210 | ---------------------------------------------------------------- | |
211 | ||
212 | Visual Studio 2005 includes 64-bit compilers, though they are not installed by | |
213 | default; you need to select them during the installation. Both native 64-bit | |
214 | compilers and 32-bit hosted cross compilers are included, so you do not need a | |
215 | 64-bit machine to use them (though you do to run the created executables). | |
216 | Visual C++ Express Edition does not include 64-bit compilers. | |
217 | ||
218 | 64-bit compilers are also available in various SDKs, for example | |
219 | the .NET Framework SDK: | |
220 | http://msdn.microsoft.com/netframework/programming/64bit/devtools/ | |
221 | ||
222 | Using project files: | |
223 | ||
224 | 1. Open the VC++ 6 workspace file: build\msw\wx.dsw. Visual Studio will then | |
225 | convert the projects to the current Visual C++ project format. | |
226 | ||
227 | 2. To add 64-bit targets, go to the 'Build' menu and choose 'Configuration | |
228 | Manager...'. In the 'Active solution platform' drop down choose '<new>', | |
229 | then you can choose either 'Itanium' or 'x64'. | |
230 | ||
231 | For more detailed instructions see: | |
232 | http://msdn2.microsoft.com/en-us/library/9yb4317s(en-us,vs.80).aspx | |
233 | ||
234 | Note: 64-bit targets created this way will use the build directory of the | |
235 | corresponding 32-bit target for some files. Therefore after building | |
236 | for one CPU it is necessary to clean the build before building the | |
237 | equivalent target for another CPU. We've reported the problem to MS | |
238 | but they say it is not possible to fix it. | |
239 | ||
240 | 3. To build, go to the 'Build' menu and choose 'Batch Build...'. Tick all the | |
241 | all the 'x64|Debug' or all the 'Itanium|Debug' projects, and click 'Build'. | |
242 | ||
243 | This will build a debug version of the static libs. The section above on | |
244 | Visual C++ in general has more information about adjusting the settings to | |
245 | build other configurations. | |
246 | ||
247 | 4. To compile one of the samples open one of the sample projects, such as | |
248 | samples\minimal\minimal.dsw. Visual Studio will convert the project as in | |
249 | step 1, then add a 64-bit target as in step 2, and build. | |
250 | ||
251 | Using makefiles: | |
252 | ||
253 | 1. Open a 64-bit build command prompt, for either x64 or Itanium. Change | |
254 | directory to build\msw. Then for x64 type: | |
255 | ||
256 | nmake -f makefile.vc TARGET_CPU=AMD64 | |
257 | ||
258 | or for Itanium: | |
259 | ||
260 | nmake -f makefile.vc TARGET_CPU=IA64 | |
261 | ||
262 | This will build a debug version of wxWidgets DLLs. See "Configuring the | |
263 | build" for instruction how to build other configurations such as a release | |
264 | build or static libraries. | |
265 | ||
266 | 2. Change to the directory of one of the samples such as samples\minimal. Type | |
267 | the same command used to build the main library, for example for x64: | |
268 | ||
269 | nmake -f makefile.vc TARGET_CPU=AMD64 | |
270 | ||
271 | Notes: | |
272 | ||
273 | The versions of the VC++ 8 compiler included with some SDKs requires an | |
274 | additional library to be linked or the following error is received. | |
275 | ||
276 | LNK2001 unresolved external symbol __security_check_cookie | |
277 | ||
278 | If you receive this error add bufferoverflowu.lib to link, e.g.: | |
279 | ||
280 | nmake -f makefile.vc TARGET_CPU=AMD64 LDFLAGS=bufferoverflowu.lib | |
281 | ||
282 | See http://support.microsoft.com/?id=894573 for more information. | |
283 | ||
284 | Borland C++ Compilation | |
285 | ---------------------------------------------------------------- | |
286 | ||
287 | The minimum version required is 5.5 (last version supported by BC++ 5.0 was | |
288 | 2.4.2), which can be downloaded for free from: | |
289 | http://www.borland.com/products/downloads/download_cbuilder.html | |
290 | ||
291 | We have found that the free Turbo Explorer and commercial BDS work fine; the | |
292 | debugger is very good. To avoid linker errors you will need to add | |
293 | -DSHARED=1 to the makefile line for the library | |
294 | ||
295 | The version 5.6 included in Borland C++ Builder 2006 works as well after the | |
296 | following small change: please remove the test for __WINDOWS__ from line 88 | |
297 | of the file BCCDIR\include\stl\_threads.h. | |
298 | ||
299 | Compiling using the makefiles: | |
300 | ||
301 | 1. Change directory to build\msw. Type 'make -f makefile.bcc' to | |
302 | make the wxWidgets core library. Ignore the compiler warnings. | |
303 | This produces a couple of libraries in the lib\bcc_lib directory. | |
304 | ||
305 | 2. Change directory to a sample or demo such as samples\minimal, and type | |
306 | 'make -f makefile.bcc'. This produces a windows exe file - by default | |
307 | in the bcc_mswd subdirectory. | |
308 | ||
309 | Note (1): the wxWidgets makefiles assume dword structure alignment. Please | |
310 | make sure that your own project or makefile settings use the | |
311 | same alignment, or you could experience mysterious crashes. To | |
312 | change the alignment, change CPPFLAGS in build\msw\config.bcc. | |
313 | ||
314 | Note (2): If you wish debug messages to be sent to the console in | |
315 | debug mode, edit makefile.bcc and change /aa to /Tpe in link commands. | |
316 | ||
317 | Using the Debugger and IDE in BDS or Turbo Explorer | |
318 | --------------------------------------------------- | |
319 | ||
320 | Doubleclick / open samples\minimal\borland.bdsproj. The current version | |
321 | is to be used with a dynamic build of wxWidgets-made by running | |
322 | make -f Makefile.bcc -DBUILD=debug -DSHARED=1 | |
323 | in wxWidgets\build\msw. You also need the wxWidgets\lib\bcc_dll | |
324 | directory in your PATH. The debugger tracks your source and also | |
325 | traces into the wxWidgets sources. | |
326 | ||
327 | To use this to debug other samples, copy the borland_ide.cpp | |
328 | and borland.bdsproj files, then replace all occurrences of | |
329 | "minimal" with the name of the new project files | |
330 | ||
331 | Compilation succeeds with CBuilderX personal edition and CBuilder6, but | |
332 | you may have to copy make.exe from the 5.5 download to the new bin directory. | |
333 | ||
334 | Compiling using the IDE files for Borland C++ 5.0 and using CBuilder IDE | |
335 | (v1-v6): not supported | |
336 | ||
337 | ||
338 | ** REMEMBER ** | |
339 | In all of your wxWidgets applications, your source code should include | |
340 | the following preprocessor directive: | |
341 | ||
342 | #ifdef __BORLANDC__ | |
343 | #pragma hdrstop | |
344 | #endif | |
345 | ||
346 | (check the samples -- e.g., \wx2\samples\minimal\minimal.cpp -- for | |
347 | more details) | |
348 | ||
349 | Borland 16 Bit Compilation for Windows 3.1 | |
350 | ---------------------------------------------------------------- | |
351 | ||
352 | The last version of wxWidgets to support 16-bit compilation with Borland was | |
353 | 2.2.7 - Please download and read the instructions in that release | |
354 | ||
355 | Watcom C++ 10.6/11 and OpenWatcom Compilation | |
356 | ---------------------------------------------------------------- | |
357 | ||
358 | 1. Change directory to build\msw. Type 'wmake -f makefile.wat' to | |
359 | make the wxWidgets core library. | |
360 | ||
361 | 2. Change directory to samples\minimal and type 'wmake -f makefile.wat' | |
362 | to make this sample. Repeat for other samples of interest. | |
363 | ||
364 | Note (1): if variant.cpp is compiled with date/time class options, the linker | |
365 | gives up. So the date/time option is switched off for Watcom C++. | |
366 | Also, wxAutomationObject is not compiled with Watcom C++ 10. | |
367 | ||
368 | Note (2): RawBitmaps won't work at present because they use unsupported template | |
369 | classes | |
370 | ||
371 | Note (3): if Watcom can't read the precompiled header when building a sample, | |
372 | try deleting .pch files in build\msw\wat_* and compiling | |
373 | the sample again. | |
374 | ||
375 | Note (4): wxUSE_STD_STRING is disabled in wx/string.h for Watcom as this | |
376 | compiler doesn't come with standard C++ library headers by default. | |
377 | If you install STLPort or another STL implementation, you'll need to | |
378 | edit wx/string.h and remove the check for Digital Mars in it (search | |
379 | for __WATCOM__). | |
380 | ||
381 | ||
382 | Metrowerks CodeWarrior Compilation | |
383 | ---------------------------------------------------------------- | |
384 | ||
385 | ** NOTE: We don't use Metrowerks compiler any more and so depend on | |
386 | ** your contributions to keep it up to date. It is possible that | |
387 | ** the project files mentioned below are out of date due to recently | |
388 | ** added files, please add them manually if you get linking errors. | |
389 | ** The authoritative list of files is in build/bakefiles/files.bkl | |
390 | ||
391 | 1. CodeWarrior Pro 7 project files in XML format are already | |
392 | included in wxMSW-2.8.x.zip and the setup version. | |
393 | ||
394 | 2. Review the file include\wx\msw\setup.h (or include\wx\msw\setup0.h if | |
395 | you are working from the SVN version) to make sure the settings reflect | |
396 | what you want. If you aren't sure, leave it alone and go with the | |
397 | default settings. A few notes: | |
398 | - Don't use wxUSE_DEBUG_NEW_ALWAYS: it doesn't mix well with MSL | |
399 | - wxUSE_GLOBAL_MEMORY_OPERATORS works, but memory leak reports | |
400 | will be rather confusing due to interactions with the MSL ANSI | |
401 | and runtime libs. | |
402 | ||
403 | 3. The project file to build the Win32 wxWidgets libraries relies on the | |
404 | Batch File Runner plug-in. This plug-in is not installed as part of | |
405 | a normal CW7 installation. However, you can find this plug-in on the | |
406 | CodeWarrior Reference CD, in the Thrill Seekers folder; it's called the | |
407 | "Batch File Post Linker". | |
408 | ||
409 | 4. If you choose not to install the Batch File Runner plug-in, then you | |
410 | need to do the following by hand: | |
411 | (1) Create the directories lib\cw7msw\include\wx and copy the file | |
412 | include\wx\msw\setup.h (or include\wx\msw\setup0.h if you are | |
413 | working from the SVN version) to lib\cw7msw\include\wx\setup.h | |
414 | (2) Create the directories lib\cw7mswd\include\wx and copy the file | |
415 | include\wx\msw\setup.h (or include\wx\msw\setup0.h if you are | |
416 | working from the SVN version) to lib\cw7mswd\include\wx\setup.h | |
417 | ||
418 | 5. Import src\wxWidgetsW7.xml to create the project file wxWidgetsW7.mcp. | |
419 | Store this project file in directory src. You may get warnings about | |
420 | not being able to find certain project paths; ignore these warnings, the | |
421 | appropriate paths will be created during the build by the Batch File Runner. | |
422 | ||
423 | 6. Choose the wxlib Win32 debug or wxlib Win32 Release target and build. You | |
424 | will get some warnings about hidden virtual functions, illegal conversions | |
425 | from const pointers to pointers, etc., all of which you can safely ignore. | |
426 | ***Note: if you get errors that the compiler can't find "wx/setup.h", just | |
427 | stop the build and build again. These errors occur because sometimes the | |
428 | compiler starts doing its thing before the copying of setup.h has completed. | |
429 | ||
430 | 7. The following libraries will be produced depending on chosen | |
431 | target: | |
432 | - wx_x86.lib ANSI Release (static) | |
433 | - wx_x86_d.lib ANSI Debug (static) | |
434 | ||
435 | 8. Sorry, I haven't had time yet to create and test Unicode or DLL versions. | |
436 | Volunteers for this are welcome (as neither DLLs nor Unicode builds are | |
437 | big priorities for me ;). | |
438 | ||
439 | 9. CodeWarrior Pro7 project files (in XML format) are also provided for some | |
440 | of the samples. In particular, there are project files for the minimal, | |
441 | controls, dialogs, dnd, nd docview samples. You can use these project | |
442 | files as templates for the other samples and for your own projects. | |
443 | - For example, to make a project file for the "grid" sample, | |
444 | just copy the project file for the "minimal" sample, minimalW7.mcp | |
445 | (made by importing minimalW7.xml into CodeWarrior), into the | |
446 | sample/grid directory, calling it gridW7.mcp. Open | |
447 | newgridW7.mcp and revise the project by deleting the files | |
448 | minimal.rc and minimal.cpp and adding the files griddemo.rc and | |
449 | griddemo.cpp. Build and run.... | |
450 | ||
451 | ||
452 | Cygwin/MinGW Compilation | |
453 | ---------------------------------------------------------------- | |
454 | ||
455 | wxWidgets supports Cygwin (formerly GnuWin32) betas and | |
456 | releases, and MinGW. Cygwin can be downloaded from: | |
457 | ||
458 | http://sources.redhat.com/cygwin/ | |
459 | ||
460 | and MinGW from: | |
461 | ||
462 | http://www.mingw.org/ | |
463 | ||
464 | Both Cygwin and MinGW can be used with configure (assuming you have MSYS | |
465 | installed in case of MinGW). You will need new enough MinGW version, preferably | |
466 | MinGW 2.0 (ships with gcc3) or at least 1.0 (gcc-2.95.3). GCC versions older | |
467 | than 2.95.3 don't work; you can use wxWidgets 2.4 with them. | |
468 | ||
469 | NOTE: some notes specific to old Cygwin (< 1.1.x) are at the end of this | |
470 | section (see OLD VERSIONS) | |
471 | ||
472 | There are two methods of compiling wxWidgets, by using the | |
473 | makefiles provided or by using 'configure'. | |
474 | ||
475 | Retrieve and install the latest version of Cygwin, or MinGW, as per | |
476 | the instructions with either of these packages. | |
477 | ||
478 | If using MinGW, you can download the add-on MSYS package to | |
479 | provide Unix-like tools that you'll need to build wxWidgets using configure. | |
480 | ||
481 | Using makefiles Directly | |
482 | ---------------------------------------------------------------- | |
483 | ||
484 | NOTE: The makefile.gcc makefiles are for compilation under MinGW using | |
485 | Windows command interpreter (command.com/cmd.exe), they won't work in | |
486 | other environments (such as UNIX or Unix-like, e.g. MSYS where you have | |
487 | to use configure instead, see the section below) | |
488 | ||
489 | Use the makefile.gcc files for compiling wxWidgets and samples, | |
490 | e.g. to compile a debugging version of wxWidgets: | |
491 | > cd c:\wx\build\msw | |
492 | > mingw32-make -f makefile.gcc BUILD=debug | |
493 | > cd c:\wx\samples\minimal | |
494 | > mingw32-make -f makefile.gcc BUILD=debug | |
495 | (See below for more options.) | |
496 | ||
497 | Notice that Windows command interpreter (cmd.exe) and mingw32-make must be | |
498 | used, using Bash (sh.exe) and make.exe from MSYS will only work when using | |
499 | configure-based build procedure described below! | |
500 | ||
501 | You can also use the 'strip' command to reduce executable/dll size (note that | |
502 | stripping an executable/dll will remove debug information!). | |
503 | ||
504 | All targets have 'clean' targets to allow removal of object files | |
505 | and other intermediate compiler files. | |
506 | ||
507 | Using configure | |
508 | ---------------------------------------------------------------- | |
509 | ||
510 | Instead of using the makefiles, you can use the configure | |
511 | system to generate appropriate makefiles, as used on Unix | |
512 | and Mac OS X systems. | |
513 | ||
514 | Change directory to the root of the wxWidgets distribution, | |
515 | make a build directory, and run configure and make in this directory. | |
516 | ||
517 | For example: | |
518 | ||
519 | cd $WXWIN | |
520 | mkdir build-debug | |
521 | cd build-debug | |
522 | ../configure --with-msw --enable-debug --enable-debug_gdb --disable-shared | |
523 | make | |
524 | make install % This step is optional, see note (6) below. | |
525 | cd samples/minimal | |
526 | make | |
527 | ./minimal.exe | |
528 | ||
529 | Notes: | |
530 | ||
531 | 1. See also the Cygwin/MinGW on the web site or CD-ROM for | |
532 | further information about using wxWidgets with these compilers. | |
533 | ||
534 | 2. libwx.a is 100 MB or more - but much less if compiled with no | |
535 | debug info (-g0) and level 4 optimization (-O4). | |
536 | ||
537 | 3. If you get a link error under MinGW 2.95.2 referring to: | |
538 | ||
539 | EnumDAdvise__11IDataObjectPP13IEnumSTATDATA@8 | |
540 | ||
541 | then you need to edit the file objidl.h at line 663 and add | |
542 | a missing PURE keyword: | |
543 | ||
544 | STDMETHOD(EnumDAdvise)(THIS_ IEnumSTATDATA**) PURE; | |
545 | ||
546 | 4. There's a bug in MinGW headers for some early distributions. | |
547 | ||
548 | in include/windows32/defines.h, where it says: | |
549 | ||
550 | #define LPSTR_TEXTCALLBACKA (LPSTR)-1L) | |
551 | ||
552 | it should say: | |
553 | ||
554 | #define LPSTR_TEXTCALLBACKA ((LPSTR)-1L) | |
555 | ||
556 | (a missing bracket). | |
557 | ||
558 | 5. OpenGL support should work with MinGW as-is. However, | |
559 | if you wish to generate import libraries appropriate either for | |
560 | the MS OpenGL libraries or the SGI OpenGL libraries, go to | |
561 | include/wx/msw/gl and use: | |
562 | ||
563 | dlltool -k -d opengl.def -llibopengl.a | |
564 | ||
565 | for the SGI DLLs, or | |
566 | ||
567 | dlltool -k -d opengl32.def -llibopengl32.a | |
568 | ||
569 | and similarly for glu[32].def. | |
570 | ||
571 | 6. The 'make install' step is optional, and copies files | |
572 | as follows: | |
573 | ||
574 | /usr/local/lib - wxmswXYZd.dll.a and wxmswXYZd.dll | |
575 | /usr/local/include/wx - wxWidgets header files | |
576 | /usr/local/bin - wx-config | |
577 | ||
578 | You may need to do this if using wx-config with the | |
579 | default root path. | |
580 | ||
581 | 7. With Cygwin, you can invoke gdb --nw myfile.exe to | |
582 | debug an executable. If there are memory leaks, they will be | |
583 | flagged when the program quits. You can use Cygwin gdb | |
584 | to debug MinGW executables. | |
585 | ||
586 | 8. Note that gcc's precompiled headers do not work on current versions of | |
587 | Cygwin. If your version of Cygwin is affected you will need to use the | |
588 | --disable-precomp-headers configure option. | |
589 | ||
590 | OLD VERSIONS: | |
591 | ||
592 | - Modify the file wx/src/cygnus.bat (or mingw32.bat or mingegcs.bat) | |
593 | to set up appropriate variables, if necessary mounting drives. | |
594 | Run it before compiling. | |
595 | ||
596 | - For Cygwin, make sure there's a \tmp directory on your | |
597 | Windows drive or bison will crash (actually you don't need | |
598 | bison for ordinary wxWidgets compilation: a pre-generated .c file is | |
599 | supplied). | |
600 | ||
601 | - If using GnuWin32 b18, you will need to copy windres.exe | |
602 | from e.g. the MinGW distribution, to a directory in your path. | |
603 | ||
604 | ||
605 | Symantec & DigitalMars C++ Compilation | |
606 | ---------------------------------------------------------------- | |
607 | ||
608 | The DigitalMars compiler is a free successor to the Symantec compiler | |
609 | and can be downloaded from http://www.digitalmars.com/ | |
610 | ||
611 | 1. You need to download and unzip in turn (later packages will overwrite | |
612 | older files) | |
613 | Digital Mars C/C++ Compiler Version 8.40 or later | |
614 | Basic utilities | |
615 | from http://www.digitalmars.com/download/freecompiler.html | |
616 | ||
617 | 2. Change directory to build\msw and type 'make -f makefile.dmc' to | |
618 | make the wxWidgets core library. | |
619 | ||
620 | 3. Change directory to samples\minimal and type 'make -f makefile.dmc' | |
621 | to make this sample. Most of the other samples also work. | |
622 | ||
623 | ||
624 | Note that if you don't have the files makefile.dmc you may create them yourself | |
625 | using bakefile tool according to the instructions in build\bakefiles\README: | |
626 | ||
627 | cd build\bakefiles | |
628 | bakefile_gen -f dmars -b wx.bkl | |
629 | bakefile_gen -f dmars -b ../../samples/minimal/minimal.bkl | |
630 | ||
631 | ||
632 | Note that wxUSE_STD_STRING is disabled in wx/string.h for Digital Mars as this | |
633 | compiler doesn't come with standard C++ library headers by default. If you | |
634 | install STLPort or another STL implementation, you'll need to edit wx/string.h | |
635 | and remove the check for Digital Mars in it (search for __DMC__). | |
636 | ||
637 | ||
638 | 16-bit compilation is no longer supported. | |
639 | ||
640 | Configuring the Build | |
641 | ================================================================ | |
642 | ||
643 | So far the instructions only explain how to build release DLLs of wxWidgets | |
644 | and did not cover any configuration. It is possible to change many aspects of | |
645 | the build, including debug/release and ANSI/Unicode settings. All makefiles in | |
646 | build\msw directory use same options (with a few exceptions documented below) | |
647 | and the only difference between them is in object files and library directory | |
648 | names and in make invocation command. | |
649 | ||
650 | Changing the Settings | |
651 | ---------------------------------------------------------------- | |
652 | ||
653 | There are two ways to modify the settings: either by passing the values as | |
654 | arguments when invoking make or by editing build\msw\config.$(compiler) file | |
655 | where $(compiler) is same extension as the makefile you use has (see below). | |
656 | The latter is good for setting options that never change in your development | |
657 | process (e.g. GCC_VERSION or VENDOR). If you want to build several versions of | |
658 | wxWidgets and use them side by side, the former method is better. Settings in | |
659 | config.* files are shared by all makefiles (samples, contrib, main library), | |
660 | but if you pass the options as arguments, you must use same arguments you used | |
661 | for the library when building samples or contrib libraries! | |
662 | ||
663 | Examples of invoking make in Unicode debug build (other options described | |
664 | below are set analogically): | |
665 | ||
666 | Visual C++: | |
667 | > nmake -f makefile.vc BUILD=debug UNICODE=1 | |
668 | ||
669 | Borland C++: | |
670 | > make -f makefile.bcc -DBUILD=debug -DUNICODE=1 | |
671 | (Note that you have to use -D to set the variable, unlike in other make | |
672 | tools!) | |
673 | ||
674 | Watcom C/C++: | |
675 | > wmake -f makefile.wat BUILD=debug UNICODE=1 | |
676 | ||
677 | MinGW using native makefiles: | |
678 | > mingw32-make -f makefile.gcc BUILD=debug UNICODE=1 | |
679 | ||
680 | MinGW using configure: | |
681 | > ./configure --enable-debug --enable-unicode | |
682 | (see ./configure --help on details; configure is not covered in this | |
683 | section) | |
684 | ||
685 | Cygwin using configure: | |
686 | > ./configure --disable-precomp-headers --enable-debug --enable-unicode | |
687 | (use --disable-precomp-headers if Cygwin doesn't support precompiled | |
688 | headers) | |
689 | ||
690 | Brief explanation of options and possible values is in every | |
691 | build\msw\config.* file; more detailed description follows. | |
692 | ||
693 | Basic Options | |
694 | ---------------------------------------------------------------- | |
695 | ||
696 | BUILD=release | |
697 | Builds release version of the library. It differs from default 'debug' in | |
698 | lack of appended 'd' in name of library and uses the release CRT libraries | |
699 | instead of debug ones. Notice that even release builds do include debug | |
700 | information by default, see DEBUG_FLAG for more information about it. | |
701 | ||
702 | SHARED=1 | |
703 | Build shared libraries (DLLs). By default, DLLs are not built | |
704 | (SHARED=0). | |
705 | ||
706 | UNICODE=0 | |
707 | To build ANSI versions of the libraries, add UNICODE=0 to make invocation | |
708 | (default is UNICODE=1). If you want to be able to use Unicode version on | |
709 | Windows9x, you will need to set MSLU=1 as well. | |
710 | ||
711 | This option affect name of the library ('u' is appended) and the directory | |
712 | where the library and setup.h are store (ditto). | |
713 | ||
714 | WXUNIV=1 | |
715 | Build wxUniversal instead of native wxMSW (see | |
716 | http://www.wxwidgets.org/wxuniv.htm for more information). | |
717 | ||
718 | Advanced Options | |
719 | ---------------------------------------------------------------- | |
720 | ||
721 | MONOLITHIC=1 | |
722 | Starting with version 2.5.1, wxWidgets has the ability to be built as | |
723 | several smaller libraries instead of single big one as used to be the case | |
724 | in 2.4 and older versions. This is called "multilib build" and is the | |
725 | default behaviour of makefiles. You can still build single library | |
726 | ("monolithic build") by setting MONOLITHIC variable to 1. | |
727 | ||
728 | USE_GUI=0 | |
729 | Disable building GUI parts of the library, build only wxBase components used | |
730 | by console applications. Note that if you leave USE_GUI=1 then both wxBase | |
731 | and GUI libraries are built. If you are building monolithic library, then | |
732 | you should set wxUSE_GUI to 1 in setup.h. | |
733 | ||
734 | USE_OPENGL=1 | |
735 | Build wxmsw29_gl.lib library with OpenGL integration class wxGLCanvas. | |
736 | You must also modify your setup.h to #define wxUSE_GLCANVAS 1. Note that | |
737 | OpenGL library is always built as additional library, even in monolithic | |
738 | build! | |
739 | ||
740 | USE_HTML=0 | |
741 | Do not build wxHTML library. If MONOLITHIC=1, then you must also | |
742 | #define wxUSE_HTML 1 in setup.h. | |
743 | ||
744 | USE_XRC=0 | |
745 | Do not build XRC resources library. If MONOLITHIC=1, then you must also | |
746 | #define wxUSE_HTML 1 in setup.h. | |
747 | ||
748 | RUNTIME_LIBS=static | |
749 | Links static version of C and C++ runtime libraries into the executable, so | |
750 | that the program does not depend on DLLs provided with the compiler (e.g. | |
751 | Visual C++'s msvcrt.dll or Borland's cc3250mt.dll). | |
752 | Caution: Do not use static runtime libraries when building DLL (SHARED=1)! | |
753 | ||
754 | MSLU=1 | |
755 | Enables MSLU (Microsoft Layer for Unicode). This setting makes sense only if | |
756 | used together with UNICODE=1. If you want to be able to use Unicode version | |
757 | on Windows9x, you will need MSLU (Microsoft Layer for Unicode) runtime DLL | |
758 | and import lib. The former can be downloaded from Microsoft, the latter is | |
759 | part of the latest Platform SDK from Microsoft (see msdn.microsoft.com for | |
760 | details). An alternative implementation of import library can be downloaded | |
761 | from http://libunicows.sourceforge.net - unlike the official one, this one | |
762 | works with other compilers and does not require 300+ MB Platform SDK update. | |
763 | ||
764 | DEBUG_FLAG=0 | |
765 | DEBUG_FLAG=1 | |
766 | DEBUG_FLAG=2 | |
767 | Specifies the level of debug support in wxWidgets. Notice that | |
768 | this is independent from both BUILD and DEBUG_INFO options. By default | |
769 | always set to 1 meaning that debug support is enabled: asserts are compiled | |
770 | into the code (they are inactive by default in release builds of the | |
771 | application but can be enabled), wxLogDebug() and wxLogTrace() are available | |
772 | and __WXDEBUG__ is defined. Setting it to 0 completely disables all | |
773 | debugging code in wxWidgets while setting it to 2 enables even the time | |
774 | consuming assertions and checks which are deemed to be unsuitable for | |
775 | production environment. | |
776 | ||
777 | DEBUG_INFO=0 | |
778 | DEBUG_INFO=1 | |
779 | This option affects whether debugging information is generated. If | |
780 | omitted or set to 'default' its value is determined the value of | |
781 | the BUILD option. | |
782 | ||
783 | TARGET_CPU=AMD64|IA64 | |
784 | (VC++ only.) Set this variable to build for x86_64 systems. If unset, x86 | |
785 | build is performed. | |
786 | ||
787 | VENDOR=<your company name> | |
788 | Set this to a short string identifying your company if you are planning to | |
789 | distribute wxWidgets DLLs with your application. Default value is 'custom'. | |
790 | This string is included as part of DLL name. wxWidgets DLLs contain compiler | |
791 | name, version information and vendor name in them. For example | |
792 | wxmsw290_core_bcc_custom.dll is one of DLLs build using Borland C++ with | |
793 | default settings. If you set VENDOR=mycorp, the name will change to | |
794 | wxmsw290_core_bcc_mycorp.dll. | |
795 | ||
796 | CFG=<configuration name> | |
797 | Sets configuration name so that you can have multiple wxWidgets builds with | |
798 | different setup.h settings coexisting in same tree. See "Object and library | |
799 | directories" below for more information. | |
800 | ||
801 | COMPILER_PREFIX=<string> | |
802 | If you build with multiple versions of the same compiler, you can put | |
803 | their outputs into directories like "vc6_lib", "vc8_lib" etc. instead of | |
804 | "vc_lib" by setting this variable to e.g. "vc6". This is merely a | |
805 | convenience variable, you can achieve the same effect (but different | |
806 | directory names) with the CFG option. | |
807 | ||
808 | ||
809 | Compiler-Specific Options | |
810 | ---------------------------------------------------------------- | |
811 | ||
812 | * MinGW | |
813 | ||
814 | If you are using gcc-2.95 instead of gcc3, you must set GCC_VERSION to | |
815 | 2.95. In build\msw\config.gcc, change | |
816 | > GCC_VERSION = 3 | |
817 | to | |
818 | > GCC_VERSION = 2.95 | |
819 | ||
820 | * Visual C++ | |
821 | ||
822 | DEBUG_RUNTIME_LIBS=0 | |
823 | DEBUG_RUNTIME_LIBS=1 | |
824 | If set to 1, msvcrtd.dll is used, if to 0, msvcrt.dll is used. By default | |
825 | msvcrtd.dll is used only if the executable contains debug info and | |
826 | msvcrt.dll if it doesn't. It is sometimes desirable to build with debug info | |
827 | and still link against msvcrt.dll (e.g. when you want to ship the app to | |
828 | customers and still have usable .pdb files with debug information) and this | |
829 | setting makes it possible. | |
830 | ||
831 | Fine-tuning the Compiler | |
832 | ---------------------------------------------------------------- | |
833 | ||
834 | All makefiles have variables that you can use to specify additional options | |
835 | passed to the compiler or linker. You won't need this in most cases, but if you | |
836 | do, simply add desired flags to CFLAGS (for C compiler), CXXFLAGS (for C++ | |
837 | compiler), CPPFLAGS (for both C and C++ compiler) and LDFLAGS (the linker). | |
838 | ||
839 | Object and Library Directories | |
840 | ---------------------------------------------------------------- | |
841 | ||
842 | All object files produced during a library build are stored in a directory under | |
843 | build\msw. Its name is derived from the build settings and CFG variable and from | |
844 | the compiler name. Examples of directory names: | |
845 | ||
846 | build\msw\bcc_msw SHARED=0 | |
847 | build\msw\bcc_mswdll SHARED=1 | |
848 | build\msw\bcc_mswunivd SHARED=0, WXUNIV=1, BUILD=debug | |
849 | build\msw\vc_mswunivd ditto, with Visual C++ | |
850 | ||
851 | Libraries and DLLs are copied into a subdirectory of the lib directory with a | |
852 | name derived from the compiler and a static/DLL setting and setup.h into a | |
853 | directory with a name that contains other settings: | |
854 | ||
855 | lib\bcc_msw | |
856 | lib\bcc_lib\msw\wx\setup.h | |
857 | lib\bcc_dll | |
858 | lib\bcc_dll\msw\wx\setup.h | |
859 | lib\bcc_lib | |
860 | lib\bcc_lib\mswunivd\wx\setup.h | |
861 | lib\vc_lib | |
862 | lib\vc_lib\mswunivd\wx\setup.h | |
863 | ||
864 | Each lib\ subdirectory has wx subdirectory with setup.h as seen above. | |
865 | This file is copied there from include\wx\msw\setup.h (and if it doesn't exist, | |
866 | from include\wx\msw\setup0.h) and this is the copy of setup.h that is used by | |
867 | all samples and should be used by your apps as well. If you are doing changes | |
868 | to setup.h, you should do them in this file, _not_ in include\wx\msw\setup.h. | |
869 | ||
870 | If you set CFG to something, the value is appended to directory names. E.g. | |
871 | for CFG=MyBuild, you'll have object files in | |
872 | ||
873 | build\msw\bcc_mswMyBuild | |
874 | build\msw\bcc_mswdllMyBuild | |
875 | etc. | |
876 | ||
877 | and libraries in | |
878 | ||
879 | lib\bcc_libMyBuild | |
880 | lib\bcc_dllMyBuild | |
881 | etc. | |
882 | ||
883 | By now it is clear what CFG is for: builds with different CFG settings don't | |
884 | share any files and they use different setup.h files. For example, this allows | |
885 | you to have two static debug builds, one with wxUSE_SOCKETS=0 and one with sockets | |
886 | enabled (without CFG, both of them would be put into same directory and there | |
887 | would be conflicts between the files). | |
888 | ||
889 | ||
890 | Building Applications Using wxWidgets | |
891 | ===================================== | |
892 | ||
893 | NB: The makefiles and project files provided with wxWidgets samples show which | |
894 | flags should be used when building applications using wxWidgets so in case | |
895 | of a problem, e.g. if the instructions here are out of date, you can always | |
896 | simply copy a makefile or project file from samples\minimal or some other | |
897 | sample and adapt it to your application. | |
898 | ||
899 | Independently of the compiler and make/IDE you are using you must do the | |
900 | following to use wxWidgets: | |
901 | ||
902 | * Add $WXWIN/include to the | |
903 | - compiler | |
904 | - resource compiler | |
905 | include paths. | |
906 | * Define the following symbols for the preprocessor: | |
907 | - __WXMSW__ to ensure you use the correct wxWidgets port. | |
908 | - _UNICODE unless you want to use deprecated ANSI build of wxWidgets. | |
909 | - NDEBUG if you want to build in release mode, i.e. disable asserts. | |
910 | - WXUSINGDLL if you are using DLL build of wxWidgets. | |
911 | * Add $WXWIN/lib/prefix_lib-or-dll to the libraries path. The prefix depends | |
912 | on the compiler, by default it is "vc" for MSVC, "gcc" for g++ and so on. | |
913 | * Add the list of libraries to link with to the linker input. The exact list | |
914 | depends on which libraries you use and whether you built wxWidgets in | |
915 | monolithic or default multlib mode and basically should include all the | |
916 | relevant libraries from the directory above, e.g. "wxmsw29ud_core.lib | |
917 | wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib | |
918 | wxexpatd.lib" for a debug build of an application using the core library only | |
919 | (all wxWidgets applications use the base library). | |
920 | ||
921 | ||
922 | Microsoft Visual C++ users can simplify the linker setup by prepending the | |
923 | directory $WXWIN/msvc to the include path (it must come before $WXWIN/include | |
924 | directory!) and omitting the last step: the required libraries will be linked | |
925 | in automatically using the "#pragma comment(lib)" feature of this compiler. |