]> git.saurik.com Git - wxWidgets.git/blob - docs/tech/tn0004.htm
backport wxFontEncoding values fix
[wxWidgets.git] / docs / tech / tn0004.htm
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="Author" content="chris elliott">
6 <meta name="GENERATOR" content="Mozilla/4.7 [en] (Win95; I) [Netscape]">
7 <title>Compiling wx Samples in the Borland IDE</title>
8 </head>
9 <body>
10
11 <h2>
12 Compiling wxWindows samples with the Borland CBuilder</h2>
13
14 This document is available online <a href="http://biolpc22.york.ac.uk/wx/bc/ide.html">here</a>.<P>
15
16 <h2>
17 Before you begin</h2>
18 This refers to the <b>2.1.16</b> and 2.1.15 wxWindows distribution. It
19 is my account of trying to compile the samples so I can use the Borland
20 IDE to edit/compile/debug. I have used CBuilder 1.00 (2 patches, nice and
21 fast), CBuilder 3 (slower), and CBuilder 4 (more recently).
22
23 <p>Make sure that the wx distribution is extracted to a path with no spaces
24 in it, and preferably on the root of your drive. Borland's compilers sometimes
25 have problems with spaces and with the long paths which occur if you try
26 to place it in a tree like <tt>d:\compiler\gui\wx...</tt>
27 <h2>
28 Part 1 Build the library</h2>
29 Build the <b>wx\wx32.lib</b> and related files using the command line compiler
30 <br>Run a command prompt in the <tt>wx/src/msw</tt> directory and type
31 <p><tt>set wxwin=pathtowx</tt>
32 <br><tt>set bccdir=pathtobc4</tt>
33 <br><tt>make -f makefile.b32</tt>
34 <p>In my case this I extracted the wx distribution in <b>c:\</b> and the
35 compiler is in <b>w:\borland\cb\bin</b> so this looks:
36 <p><tt>set wxwin=c:\wx</tt>
37 <br><tt>set bccdir=w:\borland\cb</tt>
38 <br><tt>make -f makefile.b32</tt>
39 <p>If this doesn't <b>compile</b>,
40 <ul>
41 <li>
42 you've probably got the <b><tt>set wxwin</tt></b> command wrong,</li>
43
44 <li>
45 or the path was not set by the Borland setup</li>
46 </ul>
47 If this doesn't <b>link</b>,
48 <ul>
49 <li>
50 you've probably got the <b><tt>set bccdir</tt></b> command wrong</li>
51 </ul>
52
53 <hr WIDTH="100%">
54 <h2>
55 To make the samples</h2>
56
57 <h3>
58 Solution 1</h3>
59
60 <a href="http://biolpc22.york.ac.uk/wx/bc/download.html">Download</a> a zip file which contains modified
61 cpp, mak and bpr files - it will overwrite your wx distribution cpp files!
62
63 <h3>
64 Solution 2</h3>
65 Creating the files by hand. This is for the calendar sample; you will
66 have to change the names for the other samples
67 <ul>
68 <li>
69 Create a calendar.mak file [must have the same name as the cpp file] in
70 a plain text editor with <a href="http://biolpc22.york.ac.uk/wx/bc/calendar.mak">these contents</a></li>:
71 </ul>
72 <tt>#-----------------------------------------------------------------------------</tt>
73 <br><tt>#this is for Borland CBuilder IDE v1 and 3</tt>
74 <br><tt>#add a \ at the end of the lines if you editor breaks the long
75 lines up</tt>
76 <br><tt>#copy this into notepad and save from there</tt>
77 <br><tt>#-----------------------------------------------------------------------------</tt>
78 <br><tt>!ifndef BCB</tt>
79 <br><tt>BCB = $(MAKEDIR)\..</tt>
80 <br><tt>!endif</tt>
81 <br><tt>PROJECT = calendar.exe</tt>
82 <br><tt>OBJFILES =</tt>
83 <br><tt>RESFILES = calendar.res</tt>
84 <br><tt>RESDEPEN = $(RESFILES)</tt>
85 <br><tt>LIBFILES =</tt>
86 <br><tt>#-----------------------------------------------------------------------------</tt>
87 <br><tt>CFLAG1 = -Od -v -a1 -c</tt>
88 <br><tt># -Od disable optimisations -v debug -a1 byte align -c compile
89 only (matches my make for the library)</tt>
90 <br><tt>CFLAG2 = -DINC_OLE2;__WIN95__;__WXMSW__;__WINDOWS__;WIN32;__BIDE__;-I$(BCB)\include;$(BCB)\include\vcl;..\..\include;
91 -H=BC32.CSM</tt>
92 <br><tt>PFLAGS =</tt>
93 <br><tt>RFLAGS = -DINC_OLE2;__WIN95__;__WXMSW__;__WINDOWS__;WIN32;__BIDE__;
94 -I$(BCB)\include;..\..\include;</tt>
95 <br><tt>LFLAGS = -L$(BCB)\lib;$(BCB)\lib\obj;..\..\lib -aa -Tpe -v -V4.0
96 -c</tt>
97 <br><tt>IFLAGS =</tt>
98 <br><tt>LINKER = ilink32</tt>
99 <br><tt>#-----------------------------------------------------------------------------</tt>
100 <br><tt>ALLOBJ = c0w32.obj $(OBJFILES)</tt>
101 <br><tt>ALLRES = $(RESFILES)</tt>
102 <br><tt>ALLLIB = $(LIBFILES) vcl.lib xpm.lib wx32.lib ole2w32.lib import32.lib
103 odbc32.lib cw32mt.lib</tt>
104 <br><tt>#you will need to add other libraries to the line above, eg the
105 jpeg.lib for image samples</tt>
106 <br><tt>---------------------------------------------------------------------------</tt>
107 <br><tt>.autodepend</tt>
108 <br>&nbsp;
109 <p><tt>#-----------------------------------------------------------------------------</tt>
110 <br><tt>$(PROJECT): $(OBJFILES) $(RESDEPEN)</tt>
111 <p><tt>#end of file</tt>
112 <br>&nbsp;
113 <ul>
114 <li>
115 &nbsp;modify the .cpp file to include
116 <a href="http://biolpc22.york.ac.uk/wx/bc/calendar_include.cpp">these lines</a>
117 near the top</li>
118 </ul>
119 <tt>#ifdef __BIDE__</tt>
120 <br><tt>#define _NO_VCL</tt>
121 <br><tt>#include "condefs.h"</tt>
122 <br><tt>#define WinMain WinMain</tt>
123 <br><tt>&nbsp;&nbsp; // USEUNIT ("another.cpp"); // use a line like this
124 if you have more than one .cpp file</tt>
125 <br><tt>&nbsp;&nbsp;&nbsp; USERC ("calendar.rc");</tt>
126 <br><tt>#endif</tt>
127 <br>&nbsp;
128 <p>In CBuilder 1 you can use <b>Open Project</b> to open the mak file and
129 edit/compile/debug.
130 <p>In CBuilder 3 and 4, then you can use <b>Open Project</b> and choose
131 the Open Borland CBuilder 1 Project from the drop down file types. The
132 system will modify the mak file and update it for you.
133 <p>Now try compiling it in the ide.
134 <h4>
135 Hints:</h4>
136
137 <ul>
138 <li>
139 You can set it up for normal and debug modes (change the -v switch in CFLAG1
140 and LFLAG)</li>
141
142 <li>
143 If you get problems saying Project undefined, then copy the text using
144 a simple editor like notepad to the file minimal.mak (I have had problems
145 in CBuilder 1.00 with Unix style line endings)</li>
146
147 <li>
148 If you want to avoid the warnings about hiding virtual methods add
149 <b><tt>-w-hid</tt></b> to the CFLAG1 line</li>
150
151 <li>
152 the #define WinMain WinMain line allows CBuilder to think it has a non-VCL
153 <tt>main</tt> function</li>
154
155 <li>
156 the USEUNIT macros tell CBuilder which other source files to include, without
157 needing a VCL form</li>
158
159 <li>
160 the condefs.h file defines the USEUNIT macros for non-VCL use</li>
161
162 <li>
163 For the other samples, change the names of the cpp and rc files. If you
164 have multiple files, just add more USEUNIT and USERC macros</li>
165 </ul>
166
167 <h3>
168 Solution 3</h3>
169
170 <ul>
171 <li>
172 download the wxWindows-2.1.16-bcb.zip file,</li>
173
174 <li>
175 extract it</li>
176
177 <li>
178 use the <b><tt>idetomak</tt></b> (CBuilder 1) or <b><tt>idetobpr</tt></b>
179 (CBuilder 3/4) utility on the <b><tt>.ide</tt></b> file in the samples
180 directory. This modifies the cpp source and makes a "suitable" mak or bpr file
181 (at least in CBuilder 1/3/4).</li>
182
183 <li>
184 add the location of the wx/include files in the project | options
185 | directory dialog</li>
186 </ul>
187 I found in CBuilder 1 that the <tt>idetomak</tt> utility did not manage
188 to convert all the samples, but <tt>idetobpr</tt> worked OK in CBuilder
189 3 and 4. I have a report that not all the bpr files made in CBuilder 4
190 are correct
191 <h2>
192 Error with ODBC32</h2>
193 Sometimes you get an error saying that there are unresolved externals in
194 ODBC. The solution is to run a command prompt in your <b><tt>wx\lib</tt></b> directory
195 and use the <b><tt>implib</tt></b> command:
196 <p><tt>C:\wx\lib&gt;<b>implib odbc32 c:\windows\system\odbc32.dll</b></tt>
197 <p>This creates the necessary library, odbc32.lib
198 <h2>
199 Unresolved Problem</h2>
200 <tt>In Borland CBuilder 1.00 (with linker service patch) I frequently
201 get an error</tt>
202 <p><tt>Turbo Incremental Link&nbsp; Version 1.0 Copyright (c) 1997 Borland
203 International</tt>
204 <br><tt>Fatal: Assertion failed: typeInx &lt; typeCnt at "ilinkdbg.c",
205 line 2060</tt>
206 <br><tt>Fatal: Access violation.&nbsp; Program terminated.</tt>
207 <br><tt>Error: Internal failure -- retrying link...</tt>
208 <br><tt>Fatal: Assertion failed: typeInx &lt; typeCnt at "ilinkdbg.c",
209 line 2060</tt>
210 <br><tt>Fatal: Access violation.&nbsp; Program terminated.</tt>
211 <p><tt>** error 2 ** deleting minimal.exe</tt>
212 <p>I have not been able to track down why sometimes this error occurs and
213 other times it is OK. I have not seen this in Cbuilder 3 or 4.
214 <p>
215 <hr WIDTH="100%">
216 <p>Page updated on 31 May 2000 by Chris Elliott
217 </body>
218 </html>