Forum > macOS / Mac OS X

Newbie to Lazarus - Some Basic Problems

(1/2) > >>

StephenMilner:
Hi.

Apologies if this is in the wrong sub-forum.

I have installed Lazarus and FPC on a 2021 M1 MacBook Pro following a variety of recipes.

I downloaded the 3 files from here:
https://sourceforge.net/projects/lazarus/files/Lazarus%20macOS%20x86-64/Lazarus%202.2.0/

I used this to compile for ARM:
https://wiki.freepascal.org/macOS_Big_Sur_changes_for_developers#ARM64.2FAArch64.2FApple_Silicon_Support

With the following notes:
1) Before following the instructions I had to cd to /usr/local/share/fpcsrc
2) I did not install Xcode but instead followed these instructions when issuing make commands:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Note: If you have only installed the standalone Command Line Tools and not the full Xcode package, you will need to replace /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin with /Library/Developer/CommandLineTools/usr/bin and /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk with /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk3) I needed to sudo every make command to ensure the necessary permissions were there create files/directories etc.
4) This command didn't create a viable link - I had to change the FPC version number to 3.2.2

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sudo ln -sf /usr/local/lib/fpc/3.3.1/ppca64 /usr/local/bin5) my .fpc.cfg file contained the references to the Command Line Tools (See 2 above) instead of the ones listed:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#include /etc/fpc.cfg-FD/Library/Developer/CommandLineTools/usr/bin-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 6) I started the Lazarus IDE and changed the compiler executable to the /usr/local/bin/ppca64 (although after doing so the stored path in the IDE was automatically changed to /usr/local/lib/fpc/3.3.1/ppca64
7) I changed the debugger in the IDE to the LLDB Debugger

I started the Lazarus IDE and created a new Console Application Project and modified it (just the main application loop is shown for brevity):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TMyApplication.DoRun;var  ErrorMsg: String;begin  // quick check parameters  ErrorMsg:=CheckOptions('h', 'help');  if ErrorMsg<>'' then begin    ShowException(Exception.Create(ErrorMsg));    Terminate;    Exit;  end;   // parse parameters  if HasOption('h', 'help') then begin    WriteHelp;    Terminate;    Exit;  end;   { add your program here }  writeln ('Hello World');  // stop program loop  Terminate;
Upon selecting Command R the application compiles but the IDE Reports an error: Oooops, the debugger entered the error state. Save your work now ! Hit Stop and hope the best, we're pulling the plug.

However, running the created executable, it does exactly what it says on the tine

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---steve:~/Lazarus/Hello World $ ./Hello_World Hello World 
I have selected both the Dwarf 2 with sets and the Dwarf 3 debugger options.

In order to see if this was something I had inadvertently done I created a new Form Module and tried to run it. The compiler generated this error:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Compile Project, CPU: aarch64, Target: /Users/steve/tmp/project1: Exit code 1, Errors: 1Error: resource compiler "fpcres" not found, switching to external mode 
If I now close all files and re-load my Hello World application, it will no longer compile with the same error. If I close Lazarus, re-open and try and compile the Hello World Application, again I get a the fpcres error. The only way to eliminate it is to delete the Hello World files and create a new Console Application - whereupon I revert back to the debugger error.

If you could give a newbie who's fumbling around in the dark a pointer it would be much appreciated.

Let me know if you need the contents of any config or other files.

Regards,
Stephen

StephenMilner:
OK - So, I've been a bit of a numpty....

I re-read this post properly....

https://wiki.freepascal.org/Installing_Lazarus_on_macOS

The key line here is this....


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---If you are installing FPC 3.2.2 (Lazarus 2.2RC1 or later) then you don't need to compile a native Apple Silicon version because FPC 3.2.2 for macOS is a universal binary containing both Intel and aarch64 executables.
So I compiled the fixes:
https://wiki.freepascal.org/Installing_Lazarus_on_macOS#Lazarus_Fixes_2.2

All good with my Hello World.
Got an error with my Form though, and I'm not entirely sure what I'm doing, but I seem to be getting code mixing up between the 2. If I re-open the Hello World I get the same compiler error - perhaps something to with me adding the unit for the form into the path. I think I can can work this out for myself though.

The error when running the form:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Compile Project, Target: project1: Exit code 1, Errors: 4Error: linker: Undefined symbols for architecture arm64:Error: linker:   "WSRegisterBevel", referenced from:Error: ld: symbol(s) not found for architecture arm64An error occurred while linking Error: Error while linking 
I guess I'm missing something...

I't's probably something to do with the LCLWidgetType setting for the project....

The current set is cocoa.

What should I be using?

StephenMilner:
So I worked out what I was doing wrong mixing my code up.

I needed to create a new project for my empty form test, which I've now done.

The compiler is now giving this error when I try and run the new project with a single form in it.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Build File /Users/steve/Lazarus/Form/unit1.pas: Exit code 1, Errors: 1Target OS: Darwin for AArch64unit1.pas(8,22) Error: Cannot find Forms used by Unit1, incompatible ppu=/Users/steve/bin/lazarus/laz_fixes/lcl/units/aarch64-darwin/forms.ppu, package LCLBase 
So if anyone can suggest what I'm doing wrong, or more importantly point me in the correct direction so I can read about it myself....

StephenMilner:
And as if by magic, it's started working.

Would I need to Compile/Build before I run?

That's what I've just done and it seems to be fine now.

trev:
The Mac Installation FAQ in the Wiki contains the solutions to, or explanations of, some of the issues you ran into.


--- Quote ---Would I need to Compile/Build before I run?
--- End quote ---

Run will normally recompile the application if it has any changes. Occasionally you might find you need to build first if no changes are detected.

Run also runs your application using the debugger. Run w/o debugger just runs it normally. I always add a Run w/o icon (green arrow with red cross) to my icon bar especially as M1 computers treat each new compiled version as needing permission to debug.

Navigation

[0] Message Index

[#] Next page

Go to full version