Recent

Author Topic: Wingraph - {$FATAL This unit must be compiled under Win32}  (Read 8730 times)

dculp

  • Full Member
  • ***
  • Posts: 129
I'm trying to run the simplest stock Wingraph application (Hello.pas). (See Wingraph info - http://math.ubbcluj.ro/~sberinde/wingraph/)

Code: Pascal  [Select][+][-]
  1. // Hello world program
  2. program hello;
  3. {$APPTYPE GUI}
  4.  
  5. uses wingraph;
  6.  
  7. var mess   : string;
  8.     gd,gm  : smallint;
  9.     errcode: smallint;
  10.  
  11. begin
  12.   gd:=Detect;
  13.   InitGraph(gd,gm,'');
  14.   errcode:=GraphResult;
  15.   if (errcode = grOK) then
  16.   begin
  17.     mess:='Hello world by WinGraph';
  18.     OutTextXY((GetMaxX-TextWidth (mess)) div 2,
  19.               (GetMaxY-TextHeight(mess)) div 2,mess);
  20.     repeat until CloseGraphRequest;
  21.     CloseGraph;
  22.   end;
  23. end.
  24.  

The following is at the beginning of Wingraph.pas which stops compilation ("wingraph.pas(16,4) Fatal: User defined: This unit must be compiled under Win32") -

Code: Pascal  [Select][+][-]
  1. unit wingraph;
  2. {$IFNDEF WIN32}
  3.   {$FATAL This unit must be compiled under Win32} // Compiler stops here
  4. {$ENDIF}
  5.  

In \Project\Project options\Config and Target, "Win32 GUI application is checked". Underneath that is the message "Current LCL widgetset: win32".

I can force compilation by defining Win32 -

Code: Pascal  [Select][+][-]
  1. {$define WIN32} // new define
  2.  
  3. unit wingraph;
  4. {$IFNDEF WIN32}
  5.   {$FATAL This unit must be compiled under Win32} // Compiled OK now
  6. {$ENDIF}
  7.  

However, I don't think this is what the code author intended.

What should I do to get around the above compiler problem without artificially inserting the WIN32 define?

Note: This will be a console program that will only run under Windows.

Lazarus 1.6, FPC 3.0.0

Thanks,
Don C.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #1 on: May 23, 2017, 03:23:19 pm »
Win32 should be automatically defined. The question is what compiler did you install ?

what does project-> project options -> compiler options -> config and target list for TARGET OS and TARGET CPU ?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #2 on: May 23, 2017, 04:18:31 pm »
Your code is running fine with me. Here's what I did (in Lazarus):
  • "File" > "New" > "Project" > "Program" to create an empty program skeleton.
  • Paste your entire program code over the created code skeleton (i.e. replace everything with your code).
  • When I run at this state I get "Cannot find wingraph..." - this is clear because the program does not know where wingraph is. My wingraph is in d:\prog_laz\lib\wingraph, the sources are in the subfolder src. So, add this to the project path:
  • Open "Project" > "Project options" > "Paths" and type the path to wingraph\src into the top edit box "Other unit files".
  • Press F9 to compile and run --> voila!
BTW, the program does not terminate because the function "CloseGraphRequest" returns the value of an internal boolean variable which is not altered by your code.  Replace it by "KeyPressed" to terminate the program with any key press (you must add WinCrt to uses to get access to this command):
Code: Pascal  [Select][+][-]
  1. ...
  2.  uses WinGraph, WinCrt;
  3. ....
  4.   repeat until Keypressed;  // instead of "repeat until CloseGraphRequest"
  5. ...


dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #3 on: May 23, 2017, 06:22:11 pm »
Win32 should be automatically defined. The question is what compiler did you install ?

what does project-> project options -> compiler options -> config and target list for TARGET OS and TARGET CPU ?

Both of these are "(Default)". What should these be set to? (If I set these to Win32 and x86_64 compilation gives error "Error: Illegal parameter: -Twin32".)

(I'm compiling from the Lazarus IDE. Windows 7 Pro.)
« Last Edit: May 23, 2017, 06:26:35 pm by dculp »

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #4 on: May 23, 2017, 06:37:26 pm »
If I set these to Win32 and x86_64 compilation gives error "Error: Illegal parameter: -Twin32".)

Ah - wingraph does not seem to work under 64-bit. Install a Lazarus-32-bit-version, or cross-compile to 32-bit

dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #5 on: May 23, 2017, 10:33:24 pm »
If I set these to Win32 and x86_64 compilation gives error "Error: Illegal parameter: -Twin32".)

Ah - wingraph does not seem to work under 64-bit. Install a Lazarus-32-bit-version, or cross-compile to 32-bit

When I do \Help\About\Version from the Lazarus IDE, last line says "x86_64-win64-win32/win64". Also, my most recent download is fpc-3.0.0.i386-win32.exe. Are these the 32 bit versions that I need? If so, how do I get rid of the compiler errors? If not, what download versions do I need?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #6 on: May 23, 2017, 10:53:23 pm »
No, your Lazarus is 64bit, fpc is 32 bit - I don't know what happens in such a mixed case without a proper cross compiler...

You use Laz 1.6/fpc 3.0? Then you find the 32-bit versions of Lazarus and fpc here: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%201.6/lazarus-1.6.0-fpc-3.0.0-win32.exe/download. This installs both fpc and Lazarus. It will work, for sure! Although on Win-64bit as well, I do 99% of my work with the 32.bit Lazarus/fpc.

In order to leave your other version alone check "secondary installation" (or similar) in one of the first pages of the install program and specify a directory in which Lazarus stores its user settings. And instruct the installer to not write anything into the Windows registry.

BTW: Laz 1.6/fpc 3.0 is a bit outdated. The latest release versions are 1.6.4/3.0.2 (32-bit download: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%201.6.4/lazarus-1.6.4-fpc-3.0.2-win32.exe/download). Using the "secondary installation" method you can install as many versions as you like.

dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #7 on: May 24, 2017, 03:56:20 am »
In order to leave your other version alone check "secondary installation" (or similar) in one of the first pages of the install program and specify a directory in which Lazarus stores its user settings. And instruct the installer to not write anything into the Windows registry.

BTW: Laz 1.6/fpc 3.0 is a bit outdated. The latest release versions are 1.6.4/3.0.2 (32-bit download: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%201.6.4/lazarus-1.6.4-fpc-3.0.2-win32.exe/download). Using the "secondary installation" method you can install as many versions as you like.

I have downloaded 1.6.4/3.0.2. For installation I don't understand "specify a directory in which Lazarus stores its user settings". Is this an option during installation? What directory would this typically be?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #8 on: May 24, 2017, 09:09:47 am »
Let me be more specific:

At first you must make the decision whether you want to keep the old installation or not.

Case 1: No, create a new installation - just follow the installation program. Accept what the installer proposes. At the end of the setup you can decide to "Delete all user configuration files from previous installations". Since your current installation is somehow broken I'd propose to check this option. This erases the directory c:\users\<your name>\appdata\local\Lazarus - this is where Lazarus puts its configuration data by default.

Case 2: Yes, keep the old installation - in the second page of the install programm check the option "Create a new secondary installation". In the next screen (see attached screenshot) you can decide where Lazarus will store its user-specific configuration files - this is the directory you are asking for. Enter any folder you have access to. Since I have several Lazarus installations I put all configs into a common folder and name the specific installation according to the version, i.e. d:\lazarus_configs\laz164_fpc302.

A common point to note: Never install Lazarus into "c:\program files" where Windows usually puts all programs. This is because some tools used by Lazarus don't like a space in the directory name. Use c:\lazarus instead (as proposed by the installer), or - if you are not allowed to write to c: - use c:\users\<your name>\Lazarus

dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #9 on: May 24, 2017, 09:39:11 am »
I'll use case 2 (keep old installation) for the time being.

Is the configuration file fpc.cfg? Are there any other configuration files? In the IDE, can I specify a path to the configuration file(s); if so, where (I couldn't find this under the general Options or Project options)? (I want to keep all configuration files in a "simple" folder path that I can easily back up rather than in the installation path.)

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #10 on: May 24, 2017, 09:51:12 am »
Your old Lazarus installation probably has its config files in c:\users\<your name>\appdata\local\lazarus - you can look here to see the files. The config folder contains information on editor settings, installed packages, etc - essentially everything which you can change with "Tools" > "Options".

A "secondary installation" uses a user-defined folder for these settings files. This way several Lazarus versions can coexist on the same system.

Don't touch fpc.cfg unless you know what you are doing!

dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #11 on: May 24, 2017, 10:08:23 am »
Your old Lazarus installation probably has its config files in c:\users\<your name>\appdata\local\lazarus - you can look here to see the files. The config folder contains information on editor settings, installed packages, etc - essentially everything which you can change with "Tools" > "Options".

My current backup just backs up everything in the F:\Lazarus\Projects folder so I'd like my config files to be in a subfolder there. If I move the config files there, is there a way in the IDE or elsewhere to specify the new location?


wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #12 on: May 24, 2017, 10:17:36 am »
I hope we're talking of the same thing...

Anyway: The only gui to specify the folder for the config files is the installer - see screenshot some posts above. Without a gui you can edit the file lazarus.cfg (is in the same folder as lazarus.exe): it contains the path to the config folder. Or you can start Lazarus with a link, and in the link properties you specify the destination with appended "--primary_config_path=<path_to_config_folder>"

In your case, the contents of lazarus.cfg should be
Code: [Select]
--primary-config-path=F:\Lazarus\Projects\Config_Laz164_fpc302or Lazarus should be started by this commandline (or link properties):
Code: [Select]
<path_to_lazarus>\lazarus.exe --primary-config-path=F:\Lazarus\Projects\Config_Laz164_fpc302
If you have multiple Lazarus installations I'd recommend to keep their configurations apart. Therefore, I used a folder Config_Laz164_fpc302 in above example.

The configuration diectory is created automatically if it does not yet exist.
« Last Edit: May 24, 2017, 10:23:56 am by wp »

dculp

  • Full Member
  • ***
  • Posts: 129
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #13 on: May 24, 2017, 11:23:48 am »
I copied my c:\users\<your name>\appdata\local\lazarus to F:\Lazarus\__Lazarus_config_files\laz160_fpc300\lazarus. I then renamed my c:\users\<your name>\appdata\local\lazarus to c:\users\<your name>\appdata\local\Zlazarus to preserve.

I created D:\Lazarus\lazarus.cfg (where lazarus.exe is). This file contains only -
--primary_config_path=F:\Lazarus\__Lazarus_config_files\laz160_fpc300\lazarus
I closed this file.

I restarted Lazarus. It then started to configure Lazarus again (see image). I just clicked "Start IDE" and Lazarus created a new c:\users\<your name>\appdata\local\lazarus -- it just seemed to ignore the lazarus.cfg file that I had created.



wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Wingraph - {$FATAL This unit must be compiled under Win32}
« Reply #14 on: May 24, 2017, 12:46:45 pm »
You must use a dash ('-') instead of an underscore character ('_') in "primary-config-path". Sorry for this typo in the first paragraph of my previous post (the others were correct, though). Instead of using the long parameter name ('--primary-config-path', with two leading dashes, and dashes to separate the words) you can also use a short version '-pcp' (with a single leading dash).

 

TinyPortal © 2005-2018