Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Compiling and Linking with On Time RTOS-32 Borland C++ |
Borland C++On Time RTOS-32's Libbc and Include directories must be added to the compiler library and include paths. Assuming On Time RTOS-32 is installed in directory C:\OnTime, the example program Hello.c can be compiled and linked using: bcc32 -v -IC:\ONTIME\Include -LC:\ONTIME\Libbc Hello.c Rtt32.lib If you prefer to call the linker explicitly, Hello.c can be compiled and linked in two separate steps: bcc32 -c -v -IC:\ONTIME\Include hello.c tlink32 -v -c C0x32.obj Hello.obj, Hello.exe, Hello.map, C:\ONTIME\Libbc\Rtt32.lib Cw32.lib ILINK32 can be used instead of TLINK32. Demo program Hello2.c demonstrates how to eliminate the run-time system using RTTarget-32's startup code C0rtt.obj. It can be compiled using: bcc32 -c -v -IC:\Ontime\Include Hello2.c and linked (enter on one line): tlink32 -c -v C:\Ontime\Libbc\C0rtt.obj Hello2.obj, Hello2.exe,,C:\Ontime\Libbc\Rtt32.lib If Rtt32dll.dll is used instead of Rtt32.lib, any EXE or DLL which needs to call RTTarget-32 native API functions must link import library Rtt32dll.lib. Rtt32dll.lib is not required to call Win32 emulation functions. PE files produced by Borland C++ always contain two sections which must be located: section CODE and DATA. If Borland's incremental linker ILINK32 is used, these two sections are named .text and .data, respectively. Section CODE/.text contains the executable part of the program, requires only read-only access, and corresponds to segment number 1 in the map file. Section DATA/.data needs read/write access, contains both initialized and uninitialized global data, and corresponds to segment number 2 in the map file. If you want to debug the program, Locate NTSection commands must be used; otherwise, most programs should also work with command Locate Section. If the program uses statically referenced DLLs, section .idata must also be included. If exported functions must be available at run time using GetProcAddress, the .edata section is also required. If the run-time system is used, a heap with at least 64k is required. Otherwise, no heap is needed. A stack of at least 16k is recommended. If the program contains TLS (thread) variables, sections .tls and .rdata must also be included in the program image. If the program needs to access resources of the PE file at run-time, section .rsrc is also required. A typical configuration file for a program suited for debugging is: #ifsection .text // redefine some section names for ILINK32 #define CODE .text #define DATA .data #endif FillRAM HighMem #ifndef BOOT Reserve Monitor #endif Locate Header Header HighMem Locate PageTable PageTable HighMem Locate NTSection CODE HighMem // program code Locate NTSection DATA HighMem // program data Locate NTSection .tls HighMem // needed for TLS data Locate NTSection .rdata HighMem // needed for TLS data Locate Stack Stack HighMem 16k Locate Heap Heap HighMem For a program which does not use the run-time system, contains no TLS data, and does not require debugging, you could use: Locate PageTable PageTable LowMem Locate Section CODE HighMem Locate Header Header HighMem 0 4 Locate Section DATA HighMem Locate Stack Stack HighMem 16k 4 Unfortunately, the 32-bit linker integrated in the Borland C 4.5 IDE has some severe bugs. Therefore, it is strongly recommended to use the command line compiler or the command line linker for linking. However, if you prefer to use the integrated linker, always enable debug information. There is no run-time overhead if debug information is included in a PE file. If desired, the debug information can be removed after linking using Borland's command line utility Tdstrp32.exe. To enable source level debugging with Rtd32, option -v should be added to Bcc32/Tlink32/Ilink32 command lines. Please refer to the sample make files in all directories under Demobc for many examples of building programs for On Time RTOS-32. Compiling and Linking with On Time RTOS-32
|