Подключение компилятора Borland C++ 5.5
Автор: Тугаринов Сергей / Дата: 09.01.2006 / Комментариев: 18
Категория: Компиляторы
What is Borland C++ 5.5?
Inprise Corporation, [also known as Borland],the makers of Delphi, Turbo Pascal, and C++ Builder, will let you freelydownload and use their C++ 5.5 compiler. This is Borland's latest ANSI/ISOC++ compiler, the same compiler that is used in C++ Builder 5.BCC55 comes with everything you need to compile and link both console-modeand GUI programs that will run on Windows 95/98/NT/2K. Your programs willnot run on Windows 3.1 or DOS machines however.
BCC55 does not come with an Integrated Development Environment [IDE].Instead, you write your source code using a text editor, such as WindowsNotepad or SciTE. You then compile, link, and run your programs from thecommand-line. [That is, a DOS Window.] Borland also provides the text-modeTurbo Debugger as a separate [free] download.
The rest of this page will walk you through the steps necessary to download,install, and run your C++ programs using Borland C++ 5.5. You'll also learnhow to configure the SciTE programmer's editor to compile and run yourprograms without returning to the command line.
Downloading and Installing BorlandC++ 5.5
You can download the necessary files from home over the Internet. If youhave a slow connection at home [a modem] you can download all of the filesbelow from the OCC Computing Center local area network.Because of the size of the files, you'll need to use a ZIPdisk to save the program if you download it in the Computing Center.
Compiler
You can download the compiler, linker and basic command-line tools fromthis link. The latest version [August 24, 2000] is 5.5.1. You'll have toregister, but registration is free:The compiler program is about 9MB.
Other Downloads
A good source of information about the Borland command-line tools can befound on Helmut Pharo's site in Germany. (Note: the site has been downfor some time, so the link below is to an unofficial mirror.)Borland also offers some other downloads you might be interested in. Manyof them have very little to do with the command-line tools, and are quitelarge. Here are some you might want someday:You can download the TurboDebugger from this link. As with the compiler,you'll have to register, but registration is free:
http://www.borland.com/bcppbuilder/turbodebugger/
ftp://ftp.borland.com/pub/bcppbuilder/techpubs/bcb5/b5std.zip
You can download a set of FAQs [Frequently Asked Questions] from thislink. As with the documentation bundle, the majority of the material isnot relevant to the command-line compiler.
http://community.borland.com/downloads/ti-faq/cpp-faq.zip
Installing and Configuring theTools
Once you have downloaded the compiler, youwill need to install and configure it. Fortunately, this is fairly easyif you follow these directions.
Step 1: Install the Tools
The procedures that follow assume that you will install the command-linetools in a directory named C:\BCC55. If you want to install somewhere else,simply change the path when following these instructions. A. Use WindowsExplorer to find the file you just downloaded. This is a self-extracting file, so you won't need WinZip to installthe tools. Simply double-click the file. | ![]() | |
B. Double-clickthe file FreeCommandLineTools.exe. This will launch the InstallShield installationprogram. When the first screen pops up, just click Next... ![]() | ||
C. The next screen is the license screen.Read through the license and then click "I Agree". ![]() | ||
D. The next screen asks you to enter thename for the Installation Folder. There's nothing really wroing with thedefault [C:\Borland\BCC55], but I've shortened it to C:\BCC55 as previouslymentioned. ![]() | ||
E.Unless you are reinstalling, the folder you specified will not exist. AnswerYes when asked if you want to create it. | ![]() | |
F. Once you click OK, the installationprogram will uncompress each of the files and place them in the directoryyou specified. As it works, it will keep you updated with a progress dialoglike this. ![]() | ||
G.Once it has uncompressed all of the files, the installer will notify youlike this. Click OK and your done. | ![]() | |
Step 2: Configure the Tools
Before you can use the compiler you need to configure the tools for yourmachine. This process requires you to tell the operating system [Windows]where the executable files are, and to tell the compiler where the includeand library files are located. You'll also need to tell the compiler ifyou want to pass any special switches.To configure the tools we'll write one batch [BAT] file and two CFGfiles. [This assumes you are using Windows 95/98. If you are using NT,W2K, or XP, you can write a CMD file instead of a BAT file, but a BAT filewill work as well.]
| Strictly speaking, you don't need the batch file at all, if you wantto modify your system environmental variables. To do this in Windows 95/98/ME,modify the file C:\AUTOEXEC.BAT, and add the lines shown in Step3A below. In Windows NT/2000/XP, you modify the path settings using the SystemProperties dialog, which you open from the Control Panel. Select theAdvanced page on the dialog, and then click the EnvironmentalVariables button at the bottom of the page : ![]() ![]() |
We'll start by writing the batch file to configure the environment:
A. StartBC.bat
1. Open Notepadfrom the Start Menu. It's located under Accessories. | ![]() | |
2. Before youmake any changes, save the empty file as StartBC.bat in the C:\BCC55directory. If you are running Windows NT or W2K, save the file as StartBC.cmdinstead. Be sure you put quotes around the file name when you save it, or elseNotepad will save your file as StartBC.bat.txt. | ![]() | |
3. Add thefollowing two lines to your batch file, and then save it again. | ![]() |
B. bcc32.cfg
1. While youstill have Notepad open, select New from the File menu. Thiscreates a new blank document in Notepad. | ![]() | |
2. Beforeyou make any changes, save the empty file as bcc32.cfg in the C:\BCC55\BINdirectory. Note that this is not the same directory whereyou saved StartBC.bat. Be sure you put quotes around the file name when you save it,or else Notepad will save your file as bcc32.cfg.txt, which won'twork at all. | ![]() | |
3. Add thefollowing lines to your file, and then save it again. Note, however, thatif you've installed the compiler in a directory other than C:\BC55\BIN,you'll need to adjust the lines so that they reflect the actual locationof the compiler's include and library files. | ||
![]()
| ||
C. ilink32.cfg
1. While youstill have Notepad open, select New from the File menu. | ![]() | |
2. Beforeyou make any changes, save the empty file as ilink32.cfg in theC:\BCC55\BINdirectory. Note that this is not the same directory whereyou saved StartBC.bat. Be sure you put quotes around the file name when you save it,or else Notepad will save your file as ilink32.cfg.txt. | ![]() | |
3. Add thefollowing lines to your file, and then save it again. Note, however, thatif you've installed the compiler in a directory other than C:\BC55\BIN,you'll need to adjust the lines so that they reflect the actual locationof the compiler's include and library files. | ||
![]()
| ||
Step 3: Create a Shortcut
You should create a shortcut on the desktopto run the compiler. Here's are the instructions for Windows 95/98: A. Find anempty space on the desktop and right-click. Choose New>Shortcutfrom the context menu that appears. | ![]() | |
B. For Windows95/98, type the word command when asked which program to run. Thenclick Next. ![]() ![]() | ||
C. Type in a name for the shortcut, andclick Finish: ![]() | ||
D. Right-clickthe shortcut on the desktop and choose Properties from the contextmenu. | ![]() | |
E. For Windows 95/98, when the shortcut properties dialog appears, switchto the Programs tab and change the following two entries:
![]() Here's an example using Windows XP. The Dialog for NT and 2K is similar. ![]() | ||
F.When the Change Icon dialog appears, click the Browse button andlook for the file named MORICONS.DLL . In Windows 95/98/ME you'llfind it in the Windows directory; in NT/2K/XP, it should be in the Windows\System32directory. Once you open the file select the Borland C++ icon from thelist. [This isn't necessary, of course. You can use any icon you like.] Once you're finished, click the "OK" button. Close the Propertiesdialog as well. ![]() | ||
Checking Your Installation
Once you've installed BCC, simply double-clickthe icon on your desktop to initialize the compiler. You should see somethingthat looks like this. You'll see a different set of directories in yourPATHstatement than shown here, but it should start with C:\BC55\BIN;If, instead, you get an error message, double-check each of the previoussteps.
2. Check the Paths
Next, you'll want to make sure that the compiler is actually working. Todo that, you'll run the compiler and pass it the "Help" switch. At theprompt, simply type:bcc32and press Enter. You should see a list of compiler options likethis:

3. Create the Source
From the command-line, type:Notepad bcc1.cppand press ENTER. This will launch the Notepad program usingthe filename bcc1.cpp. [When Notepad asks you if you wantto create the file, answer "Yes".] Type in and save the following program,being very careful with spelling and punctuation:

3. Compile and Link
Once you've saved your file, return to the command-line, and type:bcc32 bcc1.cppand press ENTER. This will launch the compiler and the linker. Ifyou haven't made any mistakes, this is what you'll see:


The file with the extension .OBJ is the compiled machine codebefore linking. After combining library code and startup code, the .OBJfile becomes an .EXE.
4. Dynamic Linking
You can make your code considerably smaller by using dynamic linkinginstead of static linking. Dynamic linking simply means that yourprogram loads code from a runtime DLL instead of linking commoncode into the EXE file. To enable dynamic linking, add the -tWCRswitch when you compile like this:bcc32 -tWCR bcc1.cppAs you can see from this picture, the sizes of all the files are much smaller.The executable program will only run on a machine that has the BorlandC Runtime Library DLL installed, however.

5. Running your Program
To run your progam, simply type it's name at the prompt, and press ENTER.You don't have to add the .EXE extension.
Using the SciTE Editor withBCC
SciTE stands for the Scintilla Text Editor.It is a small, free programmers editor you can use to edit and compileyour C++ programs. Using SciTE is better than using Notepad, because:- SciTE "understands" C++, and color-codes your text while you type
- SciTE let's you compile your programs from inside the editor
- SciTE highlights syntax errors, and places you on the offending line
START C:\BCC55\BIN\SC1.EXENow, when you double-click your BCC shortcut, it will launch both the commandwindow, which you can use as shown in the previous section, and the SciTEeditor. Let's try it out with the same steps we used previously:
1. Create the Source
Double-click the shortcut and make sure that both your command-line andthe SciTE editor start running. Then, open bcc1.cpp from the previoussection and make a little change to the output message. You should seesomething like this: 
2. Compile Your Code
To compile your code, Choose Tools->Compile from the menu, or PressCTRL+F7:

3. Run Your Program
If your C++ program does not have any input [that is, you don't use cin,only cout], then you can run your program from within the IDE byselecting Tools->Go from the menu, or pressing F5. Your programwill run and the output will appear at the bottom of the editor like this:
4. Syntax Errors
If your program contains syntax errors, the error messages will appearat the bottom of the screen. To see how this works, edit bcc1.cpp,and replace the int in front of main() with the word ink.When you compile, you should see a message like this:

Materialson this web site © 1995-2002, Orange Coast College. All rightsreserved.Any materials may be reproducedfor non-profit purposes
Комментариев: 18 (rss)
1. mozers™ / 12.01.2006 - 13:19
2. Aibek / 30.10.2006 - 13:59
Спасибо Вам огромное за такую программу! А начал изучать Borland C++ 5.5, но интегрированной среды не нашел. По вашей инструкции все сделал и у меня компилятор заработал с вашей средой :) Только вот проблема, файл Sc1.exe и SciTEGlobal.properties от старой версии, а вот как использовать новую версию никак не врублюсь. Может подскажете?
И второе, при нажатии F1 помощь не выходит, как ее добавить?
| Цитата |
Если вы исправляли какие-либо настройки размещенные в SciTEGlobal.properties перенесите их в SciTEUser.properties.
Так же не забудьте перенести настройки CPP на новую версию редактора.
По идее перечисленного достаточно для комфортной работы со связкой Borland со SciTE.
| Цитата |
У меня выявляется следующего рода ошибка:
>g++ -pedantic -Os -c f1.cpp -o f1.o
>The system cannot find the file specified.
Вопрос: В новой версии где можно указать на исполнимый файл компилятора bcc32? Ведь сюда по ошибке она обращается к другому компилятору...
| Цитата |
В общем вам необходимо подправить файл cpp.properies, там и хранятсья настройки компилятора.
Успехов.
| Цитата |
Вот такой вопрос.... а если мне нужно использовать какой-нибудь другой компилятор?
Еще, как сделать так, чтобы программа запускалась не в окне консоли, а в своем собственном?
И еще, как вызываемой программе передать параметры (аргументы) командной строки?
| Цитата |
Если кому интересно, то вот что нужно сделать:
1) Изменить файл cpp_.properties (или другой):
command.go.$(file.patterns.cplusplus)=cmd /c start C:\\exec.bat $(FileName) $(1) $(2) $(3) $(4)
2) Создать на диске C файл exec.bat со следующим содержимым:
@ECHO OFF
%1 %2 %3 %4 %5 %6 %7 %8 %9
ECHO.
PAUSE
EXIT
После этого запускаемые вами программы будут отрабатывать свои действия в отдельном окне, а не в окне консоли SciTE.
(И никакого SC1.exe :))
| Цитата |
| Цитата |
| Цитата |
Спасибо, в общем, разобрался наконец! Я и так запускал через командную строку, догадавшись, но ессно хотелось узнать как максимально удобно, ведь некоторые вещи тут сам ника не придумаешь, надо только где глянуть.
| Цитата |
Так как SciTE не хранит настройки в системе, решил сделать вариант для флешки используя относительные пути. Немного поковырялся и вот к чему пришёл:
В корне диска есть файл SciTE.bat и папка Programs, а в ней SciTE(сам редактор) и CPP(компилятор Borland C++ 5.5).
В файле SciTE.bat три строчки:
PATH=%CD%\Programs\CPP\Bin;%PATH%
DOSKEY /INSERT
start .\Programs\SciTE\SciTE.exe
Пришлось модифицировать bcc32.cfg и ilink32.cfg, есть два варианта:
1Если использовать относительные пути то компиляция будет работать только у файлов находящихся в каталоге с SciTE.bat (в данном пимере в корне диска):
Содержимое bcc32.cfg - относительные пути:
-I".\Programs\CPP\Include"
-L".\Programs\CPP\LIB;.\Programs\CPP\LIB\PSDK"
-P
-v-
-w
-DWINVER=0x0400
-D_WIN32_WINNT=0x0400
Содержимое ilink32.cfg - относительные пути:
-v-
-x
-L".\Programs\CPP\LIB;.\Programs\CPP\LIB\PSDK"
2Если относительными путями не пользоваться то компиляция работает для любых файлов:
Содержимое bcc32.cfg - прямые пути:
-I".\Programs\CPP\Include"
-L"C:\Programs\CPP\LIB;C:\Programs\CPP\LIB\PSDK"
-P
-v-
-w
-DWINVER=0x0400
-D_WIN32_WINNT=0x0400
Содержимое ilink32.cfg - прямые пути:
-v-
-x
-L"C:\Programs\CPP\LIB;C:\Programs\CPP\LIB\PSDK"
Чтобы в SciTE работали команды выполнить и компилировать (насчёт собрать я не уверен) в файле cpp.properties изменить строку
cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
на
cc=$(SciteDefaultHome)\..\CPP\BIN\bcc32 -v- -w -O1 $(FileNameExt)
и строку
command.go.needs.$(file.patterns.cplusplus)=g++ $(ccopts) $(FileNameExt) -o $(FileName)
на
command.go.needs.$(file.patterns.cplusplus)=$(cc)
Если ещё повозиться можно сделать и ярлык вместо батника (мне нужно портативно, поэтому оставил батник).
| Цитата |
Содержимое bcc32.cfg - прямые пути:
-I"[color=red].\Programs\CPP\Include"[/color]
вместо . надо C:
| Цитата |
Цель: Создать полностью переносимый редактор C\\CPP, встроенный в TotalCommander (PE).
Действия (пишу по памяти, могу ошибится (главное идея)):
1. Списываем SciTE в TotalCommander\\Programm\\SciTE, компилятор в TotalCommander\\Programm\\BCC
2. В cpp.properties ()
ccopts=-w- -jb -j1 -Hc -c -H=$(FileName).csm -L\"$(SciteDefaultHome)\\..\\BCC\\Lib\" -I\"$(SciteDefaultHome)\\..\\BCC\\Include\" -o$(FileName).o
cc=$(SciteDefaultHome)\\..\\BCC\\Bin\\bcc32.exe $(ccopts) $(FileNameExt)
ccc=$(SciteDefaultHome)\\..\\BCC\\Bin\\bcc32.exe $(ccopts) $(FileNameExt)
3. В папке TotalCommander\\Programm\\SciTE создаем 2 bat файла:
SciTE.bat
SET PATH=%CD%/../BCC/Bin;%PATH%
start SciTE.exe
и SciTE_F4.bat
SET PATH=%1\\..\\BCC\\Bin;%PATH%
start %1\\SciTE.exe %2
4. В тотале создаем на панели ярлык на SciTE.bat, а в настройках
Правки/Просмотра указываем: %commander_path%\\Programm\\SciTE\\SciTE_F4.bat %commander_path%\\Programm\\SciTE
Для сборки следует использовать makefile. Пример (для линкера ulink):
makefile
!include makeincl.inc
ALLEXES = \\
temp.exe \\
########################### Implicit Rules #######################
.cpp.obj:
$(CPP) $(CPPFLAGS) -c {$? }
.cpp.i:
$(CPP32) $(CPPFLAGS) -c -Sr -Sd {$? }
.obj.exe:
$(LINKER) $(LINKFLAGS) $(LINKSTARTUP) $<,temp.exe,,$(LINKLIBS)
makeincl.inc
CPP = bcc32
CPP32 = cpp32
LINKER = ulink
PCHROOT=stl_pch
CCOPTS = -w- -jb -j1 -Hc -H=$(PCHROOT).csm -L\"$(MAKEDIR)\\..\\Lib\" -I\"$(MAKEDIR)\\..\\Include\"
#Compile flags:
CPPFLAGS= $(CCOPTS)
LINKFLAGS= -Gn -Gi -ap -Tpe -x -L\"$(MAKEDIR)\\..\\Lib\"
LINKSTARTUP= c0x32.obj
LINKLIBS=import32.lib cw32$(LIBSUF).lib
| Цитата |
| Цитата |
вот такое выдает с первой прогой... Вопрос где я сделал ошибку? (windows у меня на диске D, а программа на диске С)
>bcc32 -v- -w -O1 bcc1.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
bcc1.cpp:
Error E2209 bcc1.cpp 2: Unable to open include file 'iostream'
Error E2282 bcc1.cpp 3: Namespace name expected
Error E2451 bcc1.cpp 7: Undefined symbol 'cout' in function main()
Error E2451 bcc1.cpp 7: Undefined symbol 'endl' in function main()
*** 4 errors in Compile ***
>Exit code: 1
| Цитата |
Объясните пожалуйста тупому, что ИМЕННО нужно сделать, кроме как поставить точку с запятой в конце существующего пути.
| Цитата |
timus,
Люди помогите!!!
вот такое выдает с первой прогой... Вопрос где я сделал ошибку? (windows у меня на диске D, а программа на диске С)
>bcc32 -v- -w -O1 bcc1.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
bcc1.cpp:
Error E2209 bcc1.cpp 2: Unable to open include file 'iostream'
Error E2282 bcc1.cpp 3: Namespace name expected
Error E2451 bcc1.cpp 7: Undefined symbol 'cout' in function main()
Error E2451 bcc1.cpp 7: Undefined symbol 'endl' in function main()
*** 4 errors in Compile ***
>Exit code: 1
Тот же самый проблем... Что не так???
| Цитата |





















![Selecting a title for the shortcut [Create Shortcut dialog page 2].](http://scite.ruteam.ru/engine/data/upimages/tugarinov-sergey/bcc18.gif)




Один маленький ньюанс:
Обязательно уберите рекомендуемый в этой статье ключ -P из файла bcc32.cfg иначе на этапе линковки посыплются ошибки
"Error: Unresolved external '_lua_..."
Альтернативное решение - использовать урезанный пакет.