C++ Notes using Borland C++

My sincerest gratitude to the guys at Borland for offering their compiler for free...

Add EXE Information via Resource File

Ever wanted to add the version information into your exe file?

Well, you gotta do it by using a resource file.

There are two parts to this: first, is to create a resource file, compile it separately and secondly, to link it to the exe file. The first part is relatively easy. I found some examples of resource files from here and here. It looks something like this:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION    8,0,0,0
 PRODUCTVERSION 8,0,0,0
 FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
 FILEFLAGS 0x1L
 #else
 FILEFLAGS 0x0L
 #endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
{
    BLOCK "StringFileInfo"
    { 
        BLOCK "040904b0"
        {
//             VALUE "Comments",         "comment\0"
//             VALUE "CompanyName",      "comment\0"
            VALUE "FileDescription",  "Exe File\0"
            VALUE "FileVersion",      "8.0.0.0 TP\0"
//             VALUE "InternalName",     "testTP\0"
//             VALUE "LegalCopyright",   "none\0"
//             VALUE "OriginalFilename", "\0"
//             VALUE "ProductName",      "test\0"
//             VALUE "ProductVersion",   "8.0.0.0 TP\0"
        } 
    }
    BLOCK "VarFileInfo"
    {
        VALUE "Translation", 0x409, 1200
    }
}

Next, to compile this "resource.rc" file, I found this bit of information from here to be quite useful.

brc32 -r resource.re 

That command will generate a "resource.res" file and it can be linked into the .cpp file easily using

#pragma resource "resource.res"

According to that website, #pragma is a non-standard preprocessor directive that compilers will ignore if they don't recognise it.

Compile it using bcc32 normally. It should work.

To link FFTW libraries (.lib)

Assuming you have entered the borland's bin directory into your Window's path, create the .lib files from the .dll files:

implib -a fftw3-3.lib libfftw3-3.dll

implib -a fftw3f-3.lib libfftw3f-3.dll

implib -a fftw3l-3.lib libfftw3l-3.dll

The -a option adds an underscore to each cdecl function defined in your .dll file. In my case, the .lib and .dll files are located in C:\FFTW. Then, compile your .c file in this manner:

bcc32 -I"C:\FFTW" -L"C:\FFTW" complex1D.c fftw3-3.lib

Once you get the .exe file, in order to execute the file, you will need to copy the .dll file into the same folder as the .exe file. Good luck!

Note:

This method worked on one my of my 32-bit computer (filesize around 30 kB) but when i repeated this on a 64-bit computer, the .lib files were only of 1 kB and compiling with these failed.

To compile and link header files

I had a header file with another.cpp and wanted to compile it with the main.cpp. I thought normal compiling (bcc32 main.cpp) would be sufficient but man, was I wrong. I kept getting this error:

Error: Unresolved external 'something()' referenced from C:\HEADERS\MAIN.OBJ

This is actually a linking error but due to my lack of knowledge. The compiler has options to do this.

1. Compile both together:

bcc32 main.cpp another.cpp

2. Compile each separately and then link the

bcc32 -c main.cpp

bcc32 -c another.cpp

bcc32 main.o another.o

That solved my problem!