Gui Examples-Accelerator example resource file fatal error.

Started by djsb, June 18, 2022, 01:34:30 AM

Previous topic - Next topic

djsb

I'm working my way through the GUI demos and I get these errors when trying to compile Accelerator.bas with Pellesc V11


Microsoft Windows [Version 10.0.19044.1766]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>porc.bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>SETLOCAL
Compiling  with Pelles Resource Compiler
Pelles Resource Compiler, Version 11.00.0
Copyright (c) Pelle Orinius 1997-2021

Syntax:
PORC [options] input[.rc]

Options:
/C<cp>             Define codepage for NLS conversion (default: 1252)
/D<name>           Define a symbol
/E                 Preprocess only (to stdout)
/Fo<file>          Rename the output file (default: input.res)
/I<path>           Add a search path for #include files
/L<langid>         Set default language ID (default: 0x409)
/M                 Write MAKE dependencies to stdout
/N                 Append null character to all strings in the string table
/R                 Create a .res file (default, can always be omitted)
/U<name>           Undefine a symbol
/V                 Display more information
/X                 Don't search standard places for #include files
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>porc.bat Accele~1__.rc

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>SETLOCAL
Compiling Accele~1__.rc with Pelles Resource Compiler
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>Build64.Bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>BC accelerator

BCX BASIC to C/C++ Translator (c) 1999-2022 by Kevin Diggins
Version 7.8.9 (06/10/2022) Built with LLVM-CLANG for 64-bit Windows Systems
[Lines In: 41] [Lines Out: 492] [Statements: 28] [Time: 0.08 Sec's]
BCX translated [Accelerator.Bas] to [Accelerator.C] for a C Compiler


C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call porc Accele~1__.rc
PORC: Accele~1__.rc(4): fatal error: Can't find include file windows.h.

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call pw64 accelerator Accele~1__.res
Pelles C is compiling accelerator as a 64-bit Gui app
POLINK: fatal error: File not found: 'Accele~1__.res'.
Completed ...
Could Not Find C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel\accelerator__.res
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>Build.Bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>BC accelerator

BCX BASIC to C/C++ Translator (c) 1999-2022 by Kevin Diggins
Version 7.8.9 (06/10/2022) Built with LLVM-CLANG for 64-bit Windows Systems
[Lines In: 41] [Lines Out: 492] [Statements: 28] [Time: 0.05 Sec's]
BCX translated [Accelerator.Bas] to [Accelerator.C] for a C Compiler


C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call porc Accele~1__.rc
PORC: Accele~1__.rc(4): fatal error: Can't find include file windows.h.

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call pw32 accelerator Accele~1__.res
Pelles C is compiling accelerator as a 32-bit Gui app
POLINK: fatal error: File not found: 'Accele~1__.res'.
Completed ...
Could Not Find C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel\accelerator__.res
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>



As you can see, I'm using the latest version of BCX (I have the 64 bit version of BCX in the bin directory) and I'm using the batch files recommended by MrBCX. Maybe there is a problem with the file name of the resource file.

Here is the Porc.bat batch file


SETLOCAL
@echo off

SET PATH=C:\PellesC\Bin;
SET INCLUDE=C:\PellesC\Include;C:\PellesC\Include\Win;

echo Compiling %1 with Pelles Resource Compiler
call c:\pellesc\bin\porc %1
ENDLOCAL


Here is the Pw64.bat batch file


@ECHO off
SETLOCAL
IF NOT EXIST %1.c GOTO USAGE

SET  PellesCDir=C:\PellesC
SET  PATH=%PellesCDir%\Bin;%PATH%
SET  INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
SET  LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win64;%LIB%

SET  PoccOPTS=/Go /Gn /W1 /Gd /Ze /Zx -Tamd64-coff /D_WIN32_WINNT=0x501  /std:c17
SET  PolinkOPTS=/release /machine:X64 /subsystem:windows,5.01 /STACK:10485760               
SET  PolinkLIBS=kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib oleaut32.lib

ECHO Pelles C is compiling %1 as a 64-bit Gui app
call c:\pellesc\bin\pocc   %PoccOPTS%    %1.c
call c:\pellesc\bin\polink %PolinkLIBS%  %PolinkOPTS%   %1.obj %2 %3 %4 %5 %6 %7 %8 %9
ECHO Completed ...
GOTO done


:USAGE
ECHO **************************************************************
ECHO  For building 64-bit Gui apps using Pelles C Compiler
ECHO  Usage:   PW64   "C" FileName  [Optional Linker Files: 2-9]
ECHO  Example: PW64    MyGuiApp      MyIcons.res   MyManifest.res
ECHO **************************************************************
:done
ENDLOCAL


And the pw32.bat batch file

@echo off
SETLOCAL
IF NOT EXIST %1.c GOTO USAGE

SET  PellesCDir=C:\Pellesc
SET  PATH=%PellesCDir%\Bin;%PATH%
SET  INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
SET  LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win;%LIB%

SET  PoccOPTS=/Go /Gn /W1 /Gd /Ze /Zx /Tx86-coff /D_WIN32_WINNT=0x501  /std:c11
SET  PolinkOPTS=/release /machine:X86 /subsystem:windows,5.01 /STACK:10485760               
SET  PolinkLIBS=kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib oleaut32.lib

ECHO Pelles C is compiling %1 as a 32-bit Gui app
call c:\pellesc\bin\pocc   %PoccOPTS%    %1.c
call c:\pellesc\bin\polink %PolinkLIBS%  %PolinkOPTS%  %1.obj %2 %3 %4 %5 %6 %7 %8 %9
ECHO Completed ...
GOTO done


:USAGE
ECHO **************************************************************
ECHO  For building 32-bit Gui apps using Pelles C Compiler
ECHO  Usage:   PW32   "C" FileName  [Optional Linker Files: 2-9]
ECHO  Example: PW32    MyGuiApp      MyIcons.res   MyManifest.res
ECHO **************************************************************
:done
ENDLOCAL



Here is the Original Accele~1__.rc file contents


//  BCX Generated Resource File
//  Date: 04/07/04 Time: 20:08:17

#include <windows.h>


// BCX generated *.rc file listing

#define IDM_HELP 100
MyAccel ACCELERATORS
{VK_F1,IDM_HELP,VIRTKEY}



I do not know how to create a .rc file using BCX, but have tried creating a .res file using the Porc.bat batch file. As you can see above, the error message is the same. The pw64 batch files deletes any .res files in the build directory afterwards, as there is no such file there at the moment. However, the Porc batch file results in a .res file.
I hope we can resolve this issue. Thanks.

MrBcx

1) Remove Accele~1__.rc             --- that is an orphan and serves no purpose
2) Edit your copy of Build64.bat    --- remove the lines that start with del accelerator
    Your edited batch file should now only contain these three lines:
                                 BC accelerator
                                 call porc accelerator__.rc
                                 call pw64 accelerator accelerator__.res


3) Run Build64.bat                       --- observe what files are created.

Below are the files you should have in that folder, each time you run Build64.bat:
If you have these files then you are good to go.

Accelerator.Bas
Accelerator.c
accelerator.exe
accelerator.obj
ACCELERATOR__.rc
accelerator__.res

Build.Bat
Build64.bat


PORC.bat  (Pelle Orinius Resource Compiler) expects a text resource file ( .rc )
as its input.  PORC converts the .rc to a binary version (.res) that later gets linked into
the executable ( .exe ) when Build64.bat hits this line:
call pw64 accelerator accelerator__.res

     the "C" file  ---^          ^--- the binary file created by PORC

If you want to learn how to design more sophisticated resource files that can contain
everything from GUI elements (  button, combos, editboxes, etc ), accelerators, manifests,
foreign language files, even embedded binary files, then you will need to spend time inside
the Pelles C IDE and its Help file.

Another GUI demo that uses user designed resource files in BARCHART.  It's very instructive.

Report back and we'll see if you're on track.

djsb

Thanks for your reply.

Here is the result

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>Build64.Bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>BC accelerator

BCX BASIC to C/C++ Translator (c) 1999-2022 by Kevin Diggins
Version 7.8.9 (06/10/2022) Built with LLVM-CLANG for 64-bit Windows Systems
[Lines In: 41] [Lines Out: 492] [Statements: 28] [Time: 0.05 Sec's]
BCX translated [Accelerator.Bas] to [Accelerator.C] for a C Compiler


C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call porc accelerator__.rc
PORC: accelerator__.rc(4): fatal error: Can't find include file windows.h.

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call pw64 accelerator accelerator__.res
Pelles C is compiling accelerator as a 64-bit Gui app
POLINK: fatal error: File not found: 'accelerator__.res'.
Completed ...
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>


Here are the directory contents


18/06/2022  16:39    <DIR>          .
18/06/2022  16:39    <DIR>          ..
27/10/2020  21:00               902 Accelerator.Bas
18/06/2022  16:39            16,677 Accelerator.c
18/06/2022  16:39             8,891 accelerator.obj
18/06/2022  16:39               206 accelerator__.rc
18/06/2022  05:52               151 Build.Bat
18/06/2022  16:37                93 Build64.Bat
               6 File(s)         26,920 bytes
               2 Dir(s)  694,399,754,240 bytes free




And Build64.bat

BC accelerator
call porc accelerator__.rc
call pw64 accelerator accelerator__.res


Even if I copy an already existing accelerator__.res file into this directory (from the original demo directory included in the BCX distro, not the updated 2020 demo's), it still produces the same error and also the accelerator__.res file is deleted by something. Thanks.


PS I thought that my antivirus setup was interfering with the compilation but disabling it makes no difference.

MrBcx

PORC not finding "windows.h" suggest a problem with your Pelles C installation.

One thing I can suggest is modifying your Porc.bat to the following:



SETLOCAL

@echo off

SET PATH=C:\PellesC\Bin;

SET INCLUDE=C:\PellesC\Include;C:\PellesC\Include\Win;

echo Compiling %1 with Pelles Resource Compiler

call c:\pellesc\bin\porc %1 /Ic:\pellesc\include\win

ENDLOCAL



Notice that I added  /Ic:\pellesc\include\win to the second to the last line.

That explicitly tells porc where to find "windows.h"

Hopefully that helps

Robert

Quote from: djsb on June 18, 2022, 01:34:30 AM
I'm working my way through the GUI demos and I get these errors when trying to compile Accelerator.bas with Pellesc V11


Microsoft Windows [Version 10.0.19044.1766]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>porc.bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>SETLOCAL
Compiling  with Pelles Resource Compiler
Pelles Resource Compiler, Version 11.00.0
Copyright (c) Pelle Orinius 1997-2021

Syntax:
PORC [options] input[.rc]

Options:
/C<cp>             Define codepage for NLS conversion (default: 1252)
/D<name>           Define a symbol
/E                 Preprocess only (to stdout)
/Fo<file>          Rename the output file (default: input.res)
/I<path>           Add a search path for #include files
/L<langid>         Set default language ID (default: 0x409)
/M                 Write MAKE dependencies to stdout
/N                 Append null character to all strings in the string table
/R                 Create a .res file (default, can always be omitted)
/U<name>           Undefine a symbol
/V                 Display more information
/X                 Don't search standard places for #include files
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>porc.bat Accele~1__.rc

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>SETLOCAL
Compiling Accele~1__.rc with Pelles Resource Compiler
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>Build64.Bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>BC accelerator

BCX BASIC to C/C++ Translator (c) 1999-2022 by Kevin Diggins
Version 7.8.9 (06/10/2022) Built with LLVM-CLANG for 64-bit Windows Systems
[Lines In: 41] [Lines Out: 492] [Statements: 28] [Time: 0.08 Sec's]
BCX translated [Accelerator.Bas] to [Accelerator.C] for a C Compiler


C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call porc Accele~1__.rc
PORC: Accele~1__.rc(4): fatal error: Can't find include file windows.h.

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call pw64 accelerator Accele~1__.res
Pelles C is compiling accelerator as a 64-bit Gui app
POLINK: fatal error: File not found: 'Accele~1__.res'.
Completed ...
Could Not Find C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel\accelerator__.res
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>Build.Bat

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>BC accelerator

BCX BASIC to C/C++ Translator (c) 1999-2022 by Kevin Diggins
Version 7.8.9 (06/10/2022) Built with LLVM-CLANG for 64-bit Windows Systems
[Lines In: 41] [Lines Out: 492] [Statements: 28] [Time: 0.05 Sec's]
BCX translated [Accelerator.Bas] to [Accelerator.C] for a C Compiler


C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call porc Accele~1__.rc
PORC: Accele~1__.rc(4): fatal error: Can't find include file windows.h.

C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>call pw32 accelerator Accele~1__.res
Pelles C is compiling accelerator as a 32-bit Gui app
POLINK: fatal error: File not found: 'Accele~1__.res'.
Completed ...
Could Not Find C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel\accelerator__.res
C:\Users\david\Desktop\BCX_LATEST\Gui_Demo_2020\Accel>



As you can see, I'm using the latest version of BCX (I have the 64 bit version of BCX in the bin directory) and I'm using the batch files recommended by MrBCX. Maybe there is a problem with the file name of the resource file.

Here is the Porc.bat batch file


SETLOCAL
@echo off

SET PATH=C:\PellesC\Bin;
SET INCLUDE=C:\PellesC\Include;C:\PellesC\Include\Win;

echo Compiling %1 with Pelles Resource Compiler
call c:\pellesc\bin\porc %1
ENDLOCAL


Here is the Pw64.bat batch file


@ECHO off
SETLOCAL
IF NOT EXIST %1.c GOTO USAGE

SET  PellesCDir=C:\PellesC
SET  PATH=%PellesCDir%\Bin;%PATH%
SET  INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
SET  LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win64;%LIB%

SET  PoccOPTS=/Go /Gn /W1 /Gd /Ze /Zx -Tamd64-coff /D_WIN32_WINNT=0x501  /std:c17
SET  PolinkOPTS=/release /machine:X64 /subsystem:windows,5.01 /STACK:10485760               
SET  PolinkLIBS=kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib oleaut32.lib

ECHO Pelles C is compiling %1 as a 64-bit Gui app
call c:\pellesc\bin\pocc   %PoccOPTS%    %1.c
call c:\pellesc\bin\polink %PolinkLIBS%  %PolinkOPTS%   %1.obj %2 %3 %4 %5 %6 %7 %8 %9
ECHO Completed ...
GOTO done


:USAGE
ECHO **************************************************************
ECHO  For building 64-bit Gui apps using Pelles C Compiler
ECHO  Usage:   PW64   "C" FileName  [Optional Linker Files: 2-9]
ECHO  Example: PW64    MyGuiApp      MyIcons.res   MyManifest.res
ECHO **************************************************************
:done
ENDLOCAL


And the pw32.bat batch file

@echo off
SETLOCAL
IF NOT EXIST %1.c GOTO USAGE

SET  PellesCDir=C:\Pellesc
SET  PATH=%PellesCDir%\Bin;%PATH%
SET  INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
SET  LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win;%LIB%

SET  PoccOPTS=/Go /Gn /W1 /Gd /Ze /Zx /Tx86-coff /D_WIN32_WINNT=0x501  /std:c11
SET  PolinkOPTS=/release /machine:X86 /subsystem:windows,5.01 /STACK:10485760               
SET  PolinkLIBS=kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib oleaut32.lib

ECHO Pelles C is compiling %1 as a 32-bit Gui app
call c:\pellesc\bin\pocc   %PoccOPTS%    %1.c
call c:\pellesc\bin\polink %PolinkLIBS%  %PolinkOPTS%  %1.obj %2 %3 %4 %5 %6 %7 %8 %9
ECHO Completed ...
GOTO done


:USAGE
ECHO **************************************************************
ECHO  For building 32-bit Gui apps using Pelles C Compiler
ECHO  Usage:   PW32   "C" FileName  [Optional Linker Files: 2-9]
ECHO  Example: PW32    MyGuiApp      MyIcons.res   MyManifest.res
ECHO **************************************************************
:done
ENDLOCAL



Here is the Original Accele~1__.rc file contents


//  BCX Generated Resource File
//  Date: 04/07/04 Time: 20:08:17

#include <windows.h>


// BCX generated *.rc file listing

#define IDM_HELP 100
MyAccel ACCELERATORS
{VK_F1,IDM_HELP,VIRTKEY}



I do not know how to create a .rc file using BCX, but have tried creating a .res file using the Porc.bat batch file. As you can see above, the error message is the same. The pw64 batch files deletes any .res files in the build directory afterwards, as there is no such file there at the moment. However, the Porc batch file results in a .res file.
I hope we can resolve this issue. Thanks.

Hi David:

Go back to square 1. Remove Accele~1__.rc. Run povars32.bat. Run Build.bat.

When Pelles C is installed, a povars32.bat and a povars64.bat file are created, which set paths and includes for pocc, porc polink etc. The two batch files are created in the PellesInstallPath\bin\ folder. Copy these files from the bin folder where you installed Pelles to a folder that is in your PATH. Before you use the compiler linker or whatever, run povars32.bat or povars64.bat and your paths and includes will be set up properly.