Updated docs, distrib and version
[wxWidgets.git] / docs / gtk / install.txt
1 * The most simple case
2 -----------------------
3
4 If you compile wxWindows on Unix for the first time and don't 
5 like to read install instructions just do (in the base dir):
6
7 ./configure
8 make
9 su <type root password>
10 make install
11 ldconfig
12 exit
13
14
15 * The most simple errors
16 ------------------------
17
18 configure reports, that you don't have GTK 1.X installed
19 although you are certainly sure you have. Well, you have
20 installed it, but you also have another version of the
21 GTK installed, which you may need to removed including
22 other versions of glib (and its headers).
23
24 You get errors during compilation. The reason is that you
25 probably have a broken compiler, which includes almost
26 everything that is called gcc. If there is just any way
27 for you to use egcs, use egcs. We are sorry, but we cannot
28 fix gcc.
29
30 * The most simple program
31 -------------------------
32
33 Now create your super-application myfoo.app and compile anywhere 
34 with
35
36 g++ myfoo.cpp `wx-config --libs` `wx-config --cflags` -o myfoo
37
38 * General
39 -----------------------
40
41 The Unix variants of wxWindows use GNU configure. If you have 
42 problems with your make use GNU make instead.
43
44 If you have general problems with installation, read my 
45 homepage at 
46
47   http://wesley.informatik.uni-freiburg.de/~wxxt
48   
49 for newest information. If you still don't have any success,
50 please send a bug report to one of our mailing lists (see
51 my homepage) INCLUDING A DESCRIPTION OF YOUR SYSTEM AND 
52 YOUR PROBLEM, SUCH AS YOUR VERSION OF GTK, WXGTK, WHAT
53 DISTRIBUTION YOU USE AND WHAT ERROR WAS REPORTED. I know 
54 this has no effect, but I tried...
55
56 * GUI libraries
57 -----------------------
58
59 wxWindows/GTK requires the GTK+ library to be installed on your system.
60 It has to be a stable version, preferebly version 1.2.1. You can use
61 GTK 1.0.X in connection with wxWindows, but we don't support Drag'n'Drop
62 for GTK 1.0.X so you have to "configure --without-dnd". wxWindows does 
63 NOT work with the 1.1.X versions of the GTK+ library.
64
65 You can get the newest version of the GTK+ from the GTK homepage
66 at
67   http://www.gtk.org
68   
69 We also mirror GTK+ 1.2.1 at my ftp site soon. You'll find information
70 about downloading at my homepage.
71   
72 * Additional libraries
73 -----------------------
74
75 wxWindows/Gtk requires a thread library and X libraries
76 known to work with threads. This is the case on all
77 commercial Unix-Variants and all Linux-Versions that
78 are based on glibc 2 except RedHat 5.0 which is broken
79 in many aspects. As of writing this, these Linux 
80 distributions have correct glibc 2 support:
81
82  - RedHat 5.1
83  - Debian 2.0
84  - Stampede
85  - DLD 6.0
86  - SuSE 6.0
87  
88 You can enable thread support by running 
89
90 ./configure "--with-threads"
91 make clean
92 make
93 su <type root password>
94 make install
95 ldconfig
96 exit
97   
98 NB: DO NOT COMPILE WXGTK WITH GCC AND THREADS, SINCE
99 ALL PROGRAMS WILL CRASH UPON START-UP! Just always
100 use egcs and be happy.
101
102 * Create your configuration
103 -----------------------------
104
105 Usage:
106         ./configure options
107
108 If you want to use system's C and C++ compiler,
109 set environment variables CC and CCC as
110
111         % setenv CC cc
112         % setenv CCC CC
113         % ./configure options
114
115 Using the SGI native compilers, it is recommended that you
116 also set CFLAGS and CXXFLAGS before running configure. These 
117 should be set to :
118
119 CFLAGS="-mips3 -n32" 
120 CXXFLAGS="-mips3 -n32"
121
122 This is essential if you want to use the resultant binaries 
123 on any other machine than the one it was compiled on. If you 
124 have a 64bit machine (Octane) you should also do this to ensure 
125 you don't accidently build the libraries as 64bit (which is 
126 untested).
127
128 The SGI native compiler support has only been tested on Irix 6.5.
129
130 to see all the options please use:
131
132         ./configure --help
133
134 The basic philosophy is that if you want to use different
135 configurations, like a debug and a release version, 
136 or use the same source tree on different systems,
137 you have only to change the environment variable OSTYPE.
138 (Sadly this variable is not set by default on some systems
139 in some shells - on SGI's for example). So you will have to 
140 set it there. This variable HAS to be set before starting 
141 configure, so that it knows which system it tries to 
142 configure for.
143
144 Configure will complain if the system variable OSTYPE has 
145 not been defined. And Make in some circumstances as well...
146
147
148 * General options
149 -------------------
150
151 Normally, you won't have to choose a toolkit, because when
152 you download wxGTK, it will default to --with-gtk etc. But
153 if you use all of our CVS repository you have to choose a 
154 toolkit. You must do this by running configure with either of:
155
156         --with-gtk               Use the GIMP ToolKit (GTK)
157         
158         --with-motif             Use either Motif or Lesstif
159                                  Configure will look for both. 
160
161 The following options handle the kind of library you want to build.
162
163         --with-threads          Compile with thread support. Threads
164                                 support is also required for the
165                                 socket code to work.
166
167         --without-shared        Do not create shared libraries.
168
169         --without-optimise      Do not optimise the code. Can
170                                 sometimes be useful for debugging
171                                 and is required on some architectures
172                                 such as Sun with gcc 2.8.X which
173                                 would otherwise produce segvs.
174
175         --with-profile          Add profiling info to the object 
176                                 files. Currently broken, I think.
177                                 
178         --with-mem_tracing      Add built-in memory tracing. 
179                                 
180         --with-dmalloc          Use the dmalloc memory debugger.
181                                 Read more at www.letters.com/dmalloc/
182                                 
183         --with-debug_info       Add debug info to object files and
184                                 executables for use with debuggers
185                                 such as gdb (or its many frontends).
186
187         --with-debug_flag       Define __DEBUG__ and __WXDEBUG__ when
188                                 compiling. This enable wxWindows' very
189                                 useful internal debugging tricks (such
190                                 as automatically reporting illegal calls)
191                                 to work. Note that program and library
192                                 must be compiled with the same debug 
193                                 options.
194
195 * Feature Options
196 -------------------
197
198 When producing an executable that is linked statically with wxGTK
199 you'll be surprised at its immense size. This can sometimes be
200 drastically reduced by removing features from wxWindows that 
201 are not used in your program. The most relevant such features
202 are
203
204         --without-libpng        Disables PNG image format code.
205         
206         --without-libjpeg       Disables JPEG image format code.
207         
208         --without-odbc          Disables ODBC code.
209         
210         --without-wxresources   Disables the use of *.wxr type
211                                 resources.
212                 
213         --without-threads       Disables threads.
214
215         --without-sockets       Disables sockets.
216
217         --without-dnd           Disables Drag'n'Drop.
218         
219         --without-clipboard     Disables Clipboard.
220         
221         --without-serial        Disables object instance serialiasation.
222         
223         --without-streams       Disables the wxStream classes.
224         
225 Apart from disabling certain features you can very often "strip"
226 the program of its debugging information resulting in a significant
227 reduction in size.
228
229 * Compiling
230 -------------
231
232 The following must be done in the base directory (e.g. ~/wxGTK
233 or ~/wxWin or whatever)
234
235 Now the makefiles are created (by configure) and you can compile 
236 the library by typing:
237
238         make
239
240 make yourself some coffee, as it will take some time. On an old
241 386SX possibly week. During compilation, you'll get a few 
242 warning messages depending in your compiler.
243
244 if you want to be more selective:
245
246         make            will build only the base libraries
247         make samples    will build the samples
248         make user       will build everything in user
249
250 Then you may install the library and it's header files under
251 /usr/local/include/wx and /usr/local/lib respectively. You
252 have to log in as root (i.e. run "su" and enter the root
253 password) and type
254
255         make install    
256         
257 Depending on the configuration of some files, the libraries
258 and binaries will be placed in different directories.
259 The "global" binaries and libraries will be placed in:
260
261         bin/$(OSTYPE) and
262         lib/$(OSTYPE) respectively
263
264 "local" binaries and libraries will be placed in:
265
266         (basedir of that application)/$(OSTYPE).
267
268 This is also the place where all the object-files will go.
269 (Currently there arent any global binaries).
270
271 If you want to save disk space by removing unnecessary
272 object-files:
273
274          make clean
275
276 in the various directories will do the work for you.
277
278 * Creating a new Project
279 --------------------------
280
281 There are two ways to create your own project:
282
283 1) The first way uses the installed libraries and header files
284 automatically using wx-config
285
286 g++ myfoo.cpp `wx-config --libs` `wx-config --cflags` -o myfoo
287
288 Using this way, a make file for the minimal sample would look
289 like this
290
291 CC = g++
292
293 minimal: minimal.o
294     $(CC) -o minimal minimal.o `wx-config --libs` 
295
296 minimal.o: minimal.cpp mondrian.xpm
297     $(CC) `wx-config --cflags` -c minimal.cpp -o minimal.o
298
299 clean: 
300         rm -f *.o minimal
301
302 This is certain to become the standard way unless we decide
303 to sitch to tmake.
304
305 2) The other way creates a project within the source code 
306 directories of wxWindows: In this case I propose to put 
307 all contributed programs in the directory "/user", with a 
308 directory of its own.
309
310 This directory then should include the following files:
311
312 Makefile        (You can copy this one from any application in samples
313                  probably you will not need to edit this one. There is
314                  only one case where you might be interested in changing
315                  this file, but about that see later.)
316 Makefile.in     (This is the base application-Makefile template, from
317                  which the actual Makefile for each system is created.
318                  More about this later)
319
320 put ALL your source code along with all the other stuff you need for
321 your application in this directory (subdirectories are welcome).
322
323
324 ** Something about Makefiles
325 ------------------------------
326
327 On general principle it should only contain ONE line, which is as follows:
328
329         include ../../setup/general/makeapp
330
331 this will include all the necessary definitions for creating the applications
332
333 the only case where you might want to add another line is the following:
334 this version of configure also supports creation of source archives of the
335 application for easy distribution and updates to newer version of wxWindows.
336     For this purpose all files in the application-directory will be put into
337 a gziped tar-file in the full notation user/<your application>/*
338 if you want to include some other files that you want "more visible", like
339 a README.<yourApp> or a shell script for easy 
340 compilation/installation/distribution, then you have to add a variable
341
342         DISTRIBUTE_ADDITIONAL=<your files>
343
344 to the Makefile.
345 So it would look like this:
346
347         DISTRIBUTE_ADDITIONAL=README.TheApp
348         include ../../setup/general/makeapp
349
350 As we have already talked about distribution the command to create a 
351 distribution is:
352
353         make distrib
354
355 NOTE: If you are in the base directory of wxWindows it will create 
356 distribution packages for wxWindows as well as for all packages in the
357 user directory.
358     So if you want to create only packages for the files in user,
359 then go to the directory other and type:
360
361         make distrib
362
363 or if you only want one application to be created then
364 enter the specific directory and type there:
365 make distrib
366
367 All the distribution files will be put in the directory
368 distrib at the base of the wxWindows-tree (where also configure
369 and template.mak can be found).
370
371 ** Something about Makefile.in
372 --------------------------------
373
374 As you have already seen with Makefile, configure makes a lot of use
375 if the include statement in make to keep the Makefiles as simple as 
376 possible.
377
378 So basically there are only variables to define and then a include command.
379 Exception to this rule is if you have special rules for some stuff...
380 These rules should go AFTER the include statement!!!
381
382 so the general header looks like this:
383
384         # wxWindows base directory
385         WXBASEDIR=@WXBASEDIR@
386         # set the OS type for compilation
387         OS=@OS@
388         # compile a library only
389         RULE=bin
390
391 and the general footer will look like this:
392
393         # include the definitions now
394         include ../../../template.mak
395
396 the key variable is RULE, which defines what make should create
397 in this directory.
398
399 here are some examples:
400
401   RULE    description              
402   ===========================================================================
403   bin     creates a local binary (for a global binary prefix bin with g)
404           additional variables needed:
405                 BIN_TARGET      this gives the name of your application
406                 BIN_OBJ         this gives the object files needed to
407                                 link the application
408           optional variables are:
409                 BIN_SRC         this gives the list of c/c++ files for
410                                 which dependencies will be checked.
411                                 (This can be achieved with: make depend)
412                 BIN_LINK        this gives commands for additional
413                                 libraries needed to link the application
414   ---------------------------------------------------------------------------
415   bin2    creates two local binaries (for global binaries prefix bin2 with g)
416           in addition to the variables specified above you MUST also
417           provide the same variables with BIN2_ instead of BIN_
418   ---------------------------------------------------------------------------
419   lib     creates a local library (for a global binary prefix bin with g)
420           additional variables needed:
421                 LIB_TARGET      this gives the name of your library
422                 LIB_OBJ         this gives the object files needed for
423                                 the library to be build.
424           optional variables are:
425                 LIB_SRC         this gives the list of c/c++ files for
426                                 which dependencies will be checked.
427           libbin and libgbin are also possible and will need in addition
428           the variables from bin
429   ---------------------------------------------------------------------------
430   gslib   is similar to lib, but it creates a shared library if the system
431           supports it.
432           additional variables needed:
433                 LIB_MAJOR       major number of the shared library
434                 LIB_MINOR       minor number of the shared library
435   ---------------------------------------------------------------------------
436   other additional variables:
437
438           ADD_COMPILE      define additional includes/defines that
439                            are needed to compile the object files
440                            (if you need to reference some directory
441                            utils - like wxGrid -, then please 
442                            reference them with the variables defined
443                            in template.mak - e.g.: $(SRCDIR),$(UTILS),
444                            $(SAMPLES),$(OTHERS))
445
446           NEEDED_DEFINES   lists all the defines that HAVE to be set in
447                            /include/wx/setup.h to compile correctly.
448
449           SRC_DIR          lists all directories that are needed to
450                            compile. (i.e: lists all the directories,
451                            where there are source-files.) But it is 
452                            also needed to clean an object and for 
453                            machines, for which make does not support 
454                            VPATH
455
456 currently there are the following compiling rules provided:
457 object files are created for the following file extensions:
458 .c .cc .cpp
459
460 Please have a closer look at the Makefiles in this distribution.
461
462 * Platforms configure is working with
463 ---------------------------------------
464
465 Please report build succes on any machine. Especially non-
466 Linux operating systems (which I don't have).
467
468 Original author of the autoconf system for wxxt-1.66 and for this INSTALL
469 file:
470
471         Martin Sperl    sperl@dsn.ast.univie.ac.at
472         
473 Ported to wxGTK 0.1:
474
475         Wolfram Gloger  wmglo@dent.med.uni-muenchen.de
476
477 Thanks alot to both of them.
478
479 In the hope that it will be useful,
480
481         Robert Roebling roebling@sun2.ruf.uni-freiburg.de
482         
483