1 <!doctype html public 
"-//w3c//dtd html 4.0 transitional//en"> 
   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> 
  12 Compiling wxWindows samples with the Borland CBuilder
</h2> 
  14 This document is available online 
<a href=
"http://biolpc22.york.ac.uk/wx/bc/ide.html">here
</a>.
<P> 
  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).
 
  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> 
  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>,
 
  42 you've probably got the 
<b><tt>set wxwin
</tt></b> command wrong,
</li> 
  45 or the path was not set by the Borland setup
</li> 
  47 If this doesn't 
<b>link
</b>,
 
  50 you've probably got the 
<b><tt>set bccdir
</tt></b> command wrong
</li> 
  55 To make the samples
</h2> 
  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!
 
  65 Creating the files by hand. This is for the calendar sample; you will
 
  66 have to change the names for the other samples
 
  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>:
 
  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
 
  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> 
  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;
 
  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
 
  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> 
 109 <p><tt>#-----------------------------------------------------------------------------
</tt> 
 110 <br><tt>$(PROJECT): $(OBJFILES) $(RESDEPEN)
</tt> 
 111 <p><tt>#end of file
</tt> 
 115  modify the .cpp file to include
 
 116 <a href=
"http://biolpc22.york.ac.uk/wx/bc/calendar_include.cpp">these lines
</a> 
 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>   // USEUNIT ("another.cpp"); // use a line like this
 
 124 if you have more than one .cpp file
</tt> 
 125 <br><tt>    USERC ("calendar.rc");
</tt> 
 128 <p>In CBuilder 
1 you can use 
<b>Open Project
</b> to open the mak file and
 
 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.
 
 139 You can set it up for normal and debug modes (change the -v switch in CFLAG1
 
 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> 
 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> 
 152 the #define WinMain WinMain line allows CBuilder to think it has a non-VCL
 
 153 <tt>main
</tt> function
</li> 
 156 the USEUNIT macros tell CBuilder which other source files to include, without
 
 157 needing a VCL form
</li> 
 160 the condefs.h file defines the USEUNIT macros for non-VCL use
</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> 
 172 download the wxWindows-
2.1.16-bcb.zip file,
</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> 
 184 add the location of the wx/include files in the project | options
 
 185 | directory dialog
</li> 
 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 
 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
><b>implib odbc32 c:\windows\system\odbc32.dll
</b></tt> 
 197 <p>This creates the necessary library, odbc32.lib
 
 199 Unresolved Problem
</h2> 
 200 <tt>In Borland CBuilder 
1.00 (with linker service patch) I frequently
 
 202 <p><tt>Turbo Incremental Link
  Version 
1.0 Copyright (c) 
1997 Borland
 
 204 <br><tt>Fatal: Assertion failed: typeInx 
< typeCnt at "ilinkdbg.c",
 
 206 <br><tt>Fatal: Access violation.
  Program terminated.
</tt> 
 207 <br><tt>Error: Internal failure -- retrying link...
</tt> 
 208 <br><tt>Fatal: Assertion failed: typeInx 
< typeCnt at "ilinkdbg.c",
 
 210 <br><tt>Fatal: Access violation.
  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.
 
 216 <p>Page updated on 
31 May 
2000 by Chris Elliott