]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0004.htm
added rule for building wx plugins
[wxWidgets.git] / docs / tech / tn0004.htm
CommitLineData
f6bcfd97
BP
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>
12Compiling wxWindows samples with the Borland CBuilder</h2>
13
14This document is available online <a href="http://biolpc22.york.ac.uk/wx/bc/ide.html">here</a>.<P>
15
16<h2>
17Before you begin</h2>
552861bf
VZ
18This refers to the <b>2.1.16</b> and 2.1.15 wxWindows distribution. It
19is my account of trying to compile the samples so I can use the Borland
20IDE to edit/compile/debug. I have used CBuilder 1.00 (2 patches, nice and
21fast), CBuilder 3 (slower), and CBuilder 4 (more recently).
22
f6bcfd97
BP
23<p>Make sure that the wx distribution is extracted to a path with no spaces
24in it, and preferably on the root of your drive. Borland's compilers sometimes
25have problems with spaces and with the long paths which occur if you try
26to place it in a tree like <tt>d:\compiler\gui\wx...</tt>
27<h2>
28Part 1 Build the library</h2>
29Build 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>
552861bf
VZ
34<p>In my case this I extracted the wx distribution in <b>c:\</b> and the
35compiler is in <b>w:\borland\cb\bin</b> so this looks:
f6bcfd97
BP
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>
552861bf 42you've probably got the <b><tt>set wxwin</tt></b> command wrong,</li>
f6bcfd97
BP
43
44<li>
45or the path was not set by the Borland setup</li>
46</ul>
47If this doesn't <b>link</b>,
48<ul>
49<li>
552861bf 50you've probably got the <b><tt>set bccdir</tt></b> command wrong</li>
f6bcfd97
BP
51</ul>
52
53<hr WIDTH="100%">
54<h2>
55To make the samples</h2>
56
57<h3>
58Solution 1</h3>
59
2edb0bde 60<a href="http://biolpc22.york.ac.uk/wx/bc/download.html">Download</a> a zip file which contains modified
552861bf 61cpp, mak and bpr files - it will overwrite your wx distribution cpp files!
f6bcfd97 62
552861bf
VZ
63<h3>
64Solution 2</h3>
65Creating the files by hand. This is for the calendar sample; you will
f6bcfd97
BP
66have to change the names for the other samples
67<ul>
68<li>
69Create a calendar.mak file [must have the same name as the cpp file] in
552861bf 70a plain text editor with <a href="http://biolpc22.york.ac.uk/wx/bc/calendar.mak">these contents</a></li>:
f6bcfd97
BP
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
75lines 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
89only (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
103odbc32.lib cw32mt.lib</tt>
104<br><tt>#you will need to add other libraries to the line above, eg the
105jpeg.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>
552861bf
VZ
115&nbsp;modify the .cpp file to include
116<a href="http://biolpc22.york.ac.uk/wx/bc/calendar_include.cpp">these lines</a>
117near the top</li>
f6bcfd97
BP
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
124if 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
129edit/compile/debug.
552861bf 130<p>In CBuilder 3 and 4, then you can use <b>Open Project</b> and choose
f6bcfd97
BP
131the Open Borland CBuilder 1 Project from the drop down file types. The
132system will modify the mak file and update it for you.
133<p>Now try compiling it in the ide.
134<h4>
135Hints:</h4>
136
137<ul>
138<li>
552861bf 139You can set it up for normal and debug modes (change the -v switch in CFLAG1
f6bcfd97
BP
140and LFLAG)</li>
141
142<li>
143If you get problems saying Project undefined, then copy the text using
144a simple editor like notepad to the file minimal.mak (I have had problems
145in CBuilder 1.00 with Unix style line endings)</li>
146
147<li>
552861bf
VZ
148If you want to avoid the warnings about hiding virtual methods add
149<b><tt>-w-hid</tt></b> to the CFLAG1 line</li>
f6bcfd97
BP
150
151<li>
152the #define WinMain WinMain line allows CBuilder to think it has a non-VCL
552861bf 153<tt>main</tt> function</li>
f6bcfd97
BP
154
155<li>
156the USEUNIT macros tell CBuilder which other source files to include, without
157needing a VCL form</li>
158
159<li>
160the condefs.h file defines the USEUNIT macros for non-VCL use</li>
161
162<li>
163For the other samples, change the names of the cpp and rc files. If you
164have multiple files, just add more USEUNIT and USERC macros</li>
165</ul>
166
167<h3>
168Solution 3</h3>
169
170<ul>
171<li>
552861bf 172download the wxWindows-2.1.16-bcb.zip file,</li>
f6bcfd97
BP
173
174<li>
175extract it</li>
176
177<li>
552861bf 178use the <b><tt>idetomak</tt></b> (CBuilder 1) or <b><tt>idetobpr</tt></b>
f6bcfd97 179(CBuilder 3/4) utility on the <b><tt>.ide</tt></b> file in the samples
552861bf 180directory. This modifies the cpp source and makes a "suitable" mak or bpr file
f6bcfd97
BP
181(at least in CBuilder 1/3/4).</li>
182
183<li>
552861bf 184add the location of the wx/include files in the project | options
f6bcfd97
BP
185| directory dialog</li>
186</ul>
187I found in CBuilder 1 that the <tt>idetomak</tt> utility did not manage
188to convert all the samples, but <tt>idetobpr</tt> worked OK in CBuilder
2edb0bde 1893 and 4. I have a report that not all the bpr files made in CBuilder 4
f6bcfd97
BP
190are correct
191<h2>
192Error with ODBC32</h2>
2edb0bde 193Sometimes you get an error saying that there are unresolved externals in
552861bf
VZ
194ODBC. The solution is to run a command prompt in your <b><tt>wx\lib</tt></b> directory
195and 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>
f6bcfd97
BP
197<p>This creates the necessary library, odbc32.lib
198<h2>
199Unresolved Problem</h2>
552861bf 200<tt>In Borland CBuilder 1.00 (with linker service patch) I frequently
f6bcfd97
BP
201get an error</tt>
202<p><tt>Turbo Incremental Link&nbsp; Version 1.0 Copyright (c) 1997 Borland
203International</tt>
204<br><tt>Fatal: Assertion failed: typeInx &lt; typeCnt at "ilinkdbg.c",
205line 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",
209line 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
552861bf 213other times it is OK. I have not seen this in Cbuilder 3 or 4.
f6bcfd97
BP
214<p>
215<hr WIDTH="100%">
216<p>Page updated on 31 May 2000 by Chris Elliott
217</body>
218</html>