1

I have the following batch program that is used to build my Prolog program.

set /p VERSION="Enter Version:"
call "c:\Program Files (x86)\SICStus Prolog VC12 4.3.2\bin\sicstus.exe" -l build_program.pl -a %VERSION%

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"  
call "C:\Program Files (x86)\SICStus Prolog VC12 4.3.2\bin\spld.exe" --output="fox_optimizer.exe" --static "fox_optimizer.sav"



output="my_program.exe" --static "my_program.sav" --resources=VERSIONINFO.rc

the VERSION variable is read from the user and sent as a flag to the build_program.pl that does this:

:- 
    nl,nl,nl,
    prolog_flag(argv, Arguments),
    Arguments = [VersionNumber|_],
    atom_concat('fox_optimizer_',VersionNumber,FinalFileToCompile),
    nl,
    write('Trying to complile: '),
    write(FinalFileToCompile),
    nl,nl,nl,
    compile(FinalFileToCompile),
    save_program('my_program.sav'),
    halt.

besically it builds the .sav file that is then used by spld to build into .exe file.

I want to add meta-data to the build .exe and i know that wjen using c++ you have to add a resource file so i tried this ..

output="my_program.exe" --static "my_program.sav" --resources=VERSIONINFO.rc

where VERSIONINFO.rc is:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "000904b0"
        BEGIN
            VALUE "CompanyName", "Britannica Knowledge Systems"
            VALUE "FileDescription", "Fox Optimizer"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "fox_optimizer.exe"
            VALUE "LegalCopyright", "Copyright (C) 2016"
            VALUE "OriginalFilename", "fox_optimizer.exe"
            VALUE "ProductName", "Fox Optimizer"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x9, 1200
    END
END

but when running spld i get the following error

cl : Command line warning D9024 : unrecognized source file type 'VERSIONINFO.rc', object file assumed VERSIONINFO.rc : fatal error LNK1136: invalid or corrupt file

Mortalus
  • 10,574
  • 11
  • 67
  • 117

1 Answers1

1

The spld option --resources has nothing to do with Windows resources. What you want is to compile the .rc file to a .res file (using the rc tool) and pass that .res file to the C compiler (via spld) together with the other object files. Something like the following:

call "rc VERSIONINFO.rc"

call "C:\Program Files (x86)\SICStus Prolog VC12 4.3.1\bin\spld.exe" -v --output="my_program.exe" --static "my_program.sav" VERSIONINFO.res

This will embed the Windows resource file in the executable created by spld.

I added the -v flag to turn on some verbose debug information from spld. This is useful when troubleshooting.

Per Mildner
  • 10,469
  • 23
  • 30