How to compile RasterSaver for Borland C++ Builder 5 ==================================================== James Ward (www.crema.co.uk) Created: 16th August 2002 Here is a procedure for compiling the RasterSaver source code under Borland C++ Builder. This was prompted by a request from Grzegorz Krol. I know that quite a few people use Builder, so here goes... It's a bit messy, because there is no 'scrnsave.lib' for Builder as far as I know. For this reason, I might put the required LIB file: 'bcb_scrnsave.lib' on my site. Watch this space :) These instructions are not finished: this builds an application with a console window. The project options need tweaking to get rid of this. Still, it does seem to work. Here are the instructions: 0. Install the screen saver using the self-extracting installer (ie. download and install binary version first). This ensures that the requires textures and models will be found when you compile+run the project. 1. Create new project with console wizard (File.. New.. Console Wizard) 2. In Console Wizard, specify: C++ Source Don't use VCL Don't build Console Application 3. Specify project source: Pick 'MySaver.cpp' file. 4. Save project as 'RasterSaver.bpr" (File.. Save Project As..) 5. In Project Manager, click on 'RasterSaver.exe' to select it, then right click to add files. Add the following files: Saver.cpp Model.cpp 6. In Project Options, under the C++ tab, change the compatibility settings to: "Don't restrict for loop scope" Alternatively, alter the source code to correct cases where for loop scope is restricted (this is a Borland/Microsoft compiler difference). 7. Program needs 'scrnsave.lib', which is a static library supplied with MS Visual C++ and doesn't work in Borland C++ Builder. Oops. We will need to find a way to convert or recompile this lib! 8. Find source code for 'scrnsave.lib': I did a google search: scrnsave.lib skeleton.c Which finds this: http://therabbithole.redback.inficad.com/tricks/GameProgrammingStarterKit/vc/SAMPLES/SDK/SDKTOOLS/SCRNSAVE ..but I guess that won't be around forever. You can also find the source in the Microsoft SDK I think. 8a.Save the RasterSaver project, and close it. 9. Make a Borland C++ Builder 'library' project, using C files from above SDK link, build the library. You will want to pick 'Release' compiler options under: Project Options.. Compiler.. Release mode I chose to call this 'bcb_scrnsave.lib' to avoid confusion. 9a.You might need to make some source code modifications to the 'scrnsave.lib' source on your system (depending on the version of the source that you are using - I think that the one I used might date back to the WIN3.1 days). See Note 1 at end. 9b.Save the 'bcb_scrnsave' project, and close it. 10.Open the RasterSaver project again. Add the new 'bcb_scrnsave.lib' library to the RasterSaver.exe project in the Project Manager. 11.In Project Options, Application tab, set the filename extension to 'scr' instead of 'exe' 12.In Project Options, Compiler tab, select Release mode. 13.Under Run.. Parameters.. insert the following command line parameter: /s This will allow you to directly run the saver from within the IDE. 14.Add the resources to the project: 'RasterSave.rc' I needed to comment out the line: #include "afxres.h" form the resource file. Resources are needed for configuration/about dialog, but not for the saver itself. 15.Build and run the final project (F9) 16.The screen saver should start: note that the textures and models will only work if the screen saver has been already installed, since it will look for the registry keys to locate the files (failing that, it looks in default installation path). 17.OPTIONAL: Build the libraries into the executable - this avoids problems with missing DLLs, particularly when moving the EXE/SCR onto a different PC that doesn't have Builder installed: * Go to Project Options * Under 'Packages' tab, uncheck the 'Build with runtime packages' option. * Under 'Linker' tab, uncheck the 'Use dynamic RTL' option. The program shouldn't complain about missing DLLs then, but this does make the executable quite a bit larger :) --- If anyone has any corrections or ideas on a better way of doing this, please let me know. Also, if anything is unclear then get in touch and I'll update these instructions. Using the instructions here, I was able to build and run the screen saver from the IDE. best of luck! James. --- Note 1: Source changes to scrnsave.lib source code: 1. In SKELETON.C, change the declaration of DefScreenSaverProc to match the one in 'SCRNSAVE.H'. 2. In SKELETON.C, in function DoConfigureDialog when it calls the DialogBox() function, change the (WNDPROC) cast into a (DLGPROC) cast.