]> git.saurik.com Git - wxWidgets.git/blob - docs/tech/tn0004.htm
added wxEncodingToCodepage() and implemented it properly (using in32 API instead...
[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 2.1.15 wxWindows distribution. It is my account of trying
19 to compile the samples so I can use the Borland IDE to edit/compile/debug.
20 I have used CBuilder 1.00 (2 patches, nice and fast) CBuilder 3 (slower)
21 and CBuilder 4 (only occasionally)
22 <p>Make sure that the wx distribution is extracted to a path with no spaces
23 in it, and preferably on the root of your drive. Borland's compilers sometimes
24 have problems with spaces and with the long paths which occur if you try
25 to place it in a tree like <tt>d:\compiler\gui\wx...</tt>
26 <h2>
27 Part 1 Build the library</h2>
28 Build the <b>wx\wx32.lib</b> and related files using the command line compiler
29 <br>Run a command prompt in the <tt>wx/src/msw</tt> directory and type
30 <p><tt>set wxwin=pathtowx</tt>
31 <br><tt>set bccdir=pathtobc4</tt>
32 <br><tt>make -f makefile.b32</tt>
33 <p>In my case this I extracted the wx distribution in <b>c:\ </b>and the
34 compiler is in <b>w:\borland\cb\bin </b>so this looks:
35 <p><tt>set wxwin=c:\wx</tt>
36 <br><tt>set bccdir=w:\borland\cb</tt>
37 <br><tt>make -f makefile.b32</tt>
38 <p>If this doesn't <b>compile</b>,
39 <ul>
40 <li>
41 you've probably got the <b><tt>set wxwin </tt></b>command wrong,</li>
42
43 <li>
44 or the path was not set by the Borland setup</li>
45 </ul>
46 If this doesn't <b>link</b>,
47 <ul>
48 <li>
49 you've probably got the <b><tt>set bccdir </tt></b>command wrong</li>
50 </ul>
51
52 <hr WIDTH="100%">
53 <h2>
54 To make the samples</h2>
55
56 <h3>
57 Solution 1</h3>
58
59 <h4>
60 <a href="http://biolpc22.york.ac.uk/wx/bc/download.html">Download</a> a zip file which contains modifed
61 cpp, mak and bpr files - it will overwrite your wx distribution cpp files!</h4>
62
63 <h4>
64 Solution 2</h4>
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">this 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 these<a href="http://biolpc22.york.ac.uk/wx/bc/calendar_include.cpp">
116 lines </a>near the top</li>
117 </ul>
118 <tt>#ifdef __BIDE__</tt>
119 <br><tt>#define _NO_VCL</tt>
120 <br><tt>#include "condefs.h"</tt>
121 <br><tt>#define WinMain WinMain</tt>
122 <br><tt>&nbsp;&nbsp; // USEUNIT ("another.cpp"); // use a line like this
123 if you have more than one .cpp file</tt>
124 <br><tt>&nbsp;&nbsp;&nbsp; USERC ("calendar.rc");</tt>
125 <br><tt>#endif</tt>
126 <br>&nbsp;
127 <p>In CBuilder 1 you can use <b>Open Project</b> to open the mak file and
128 edit/compile/debug.
129 <br>In CBuilder 3 and 4, then you can use <b>Open Project </b>and choose
130 the Open Borland CBuilder 1 Project from the drop down file types. The
131 system will modify the mak file and update it for you.
132 <p>Now try compiling it in the ide.
133 <h4>
134 Hints:</h4>
135
136 <ul>
137 <li>
138 You can set it up for normal and debug modes (change the -v switch in CFLAG1&nbsp;
139 and LFLAG)</li>
140
141 <li>
142 If you get problems saying Project undefined, then copy the text using
143 a simple editor like notepad to the file minimal.mak (I have had problems
144 in CBuilder 1.00 with Unix style line endings)</li>
145
146 <li>
147 If you want to avoid the warnings about hiding virtual methods add <b><tt>-w-hid
148 </tt></b>to the CFLAGS1 line</li>
149
150 <li>
151 the #define WinMain WinMain line allows CBuilder to think it has a non-VCL
152 <tt>main </tt>function</li>
153
154 <li>
155 the USEUNIT macros tell CBuilder which other source files to include, without
156 needing a VCL form</li>
157
158 <li>
159 the condefs.h file defines the USEUNIT macros for non-VCL use</li>
160
161 <li>
162 For the other samples, change the names of the cpp and rc files. If you
163 have multiple files, just add more USEUNIT and USERC macros</li>
164 </ul>
165
166 <h3>
167 Solution 3</h3>
168
169 <ul>
170 <li>
171 download the wxWindows-2.1.15-bcb.zip file,</li>
172
173 <li>
174 extract it</li>
175
176 <li>
177 use the <b><tt>idetomak</tt></b> (CBuilder 1) or&nbsp; <b><tt>idetobpr</tt></b>
178 (CBuilder 3/4) utility on the <b><tt>.ide</tt></b> file in the samples
179 directory. This modifies the cpp source and makes a "suitable" bpr file
180 (at least in CBuilder 1/3/4).</li>
181
182 <li>
183 add the location of the wx/include files in the&nbsp; project | options
184 | directory dialog</li>
185 </ul>
186 I found in CBuilder 1 that the <tt>idetomak</tt> utility did not manage
187 to convert all the samples, but <tt>idetobpr</tt> worked OK in CBuilder
188 3 and 4. I have a report that not all the bpr files made inb CBuilder 4
189 are correct
190 <h2>
191 Error with ODBC32</h2>
192 Sometimes you get an error saying that there are unreolved externals in
193 ODBC. The soltuion is to run a command prompt in your <b><tt>wx\lib </tt></b>directory
194 and use the <b><tt>implib </tt></b>command:
195 <p><tt>C:\wx\lib><b>implib odbc32 c:\windows\system\odbc32.dll</b></tt>
196 <p>This creates the necessary library, odbc32.lib
197 <h2>
198 Unresolved Problem</h2>
199 <tt>In Borland CBuilder 1.00 (with linker service patch)&nbsp; I frequently
200 get an error</tt>
201 <p><tt>Turbo Incremental Link&nbsp; Version 1.0 Copyright (c) 1997 Borland
202 International</tt>
203 <br><tt>Fatal: Assertion failed: typeInx &lt; typeCnt at "ilinkdbg.c",
204 line 2060</tt>
205 <br><tt>Fatal: Access violation.&nbsp; Program terminated.</tt>
206 <br><tt>Error: Internal failure -- retrying link...</tt>
207 <br><tt>Fatal: Assertion failed: typeInx &lt; typeCnt at "ilinkdbg.c",
208 line 2060</tt>
209 <br><tt>Fatal: Access violation.&nbsp; Program terminated.</tt>
210 <p><tt>** error 2 ** deleting minimal.exe</tt>
211 <p>I have not been able to track down why sometimes this error occurs and
212 other times it is OK
213 <br>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>