Recent

Author Topic: Error Compiling in OSX Snow Leopard  (Read 21558 times)

earlcenac

  • New Member
  • *
  • Posts: 14
Error Compiling in OSX Snow Leopard
« on: November 03, 2009, 05:33:46 am »
I am also having a little trouble compiling in Snow Leopard.
 I downloaded and installed Lazarus for my Mac running Snow Leopard. I installed these files in this order.
fpc -2.2.4. intel-macosx.dmg
fpcsrc - 2.2.4 - Intel - macosx.dmg
lazarus 0.9.28.2 - i386 - macosx.dmg

When I try to run a "hello World" program I get this message "Can't find unit interfaces used by project1".

I know that it has something to do with the paths but I do not know where the files are stored on the Mac or if there is a routine to put all the correct paths.

Can anybody here help me?

didiergm

  • New Member
  • *
  • Posts: 26
Re: Error Compiling in OSX Snow Leopard
« Reply #1 on: November 03, 2009, 04:30:08 pm »
Which widgetset are you using (view in Projects/options) I got that when trying to use Cocoa; with Carbon or Default everything is fine

Didier

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Error Compiling in OSX Snow Leopard
« Reply #2 on: November 03, 2009, 04:35:52 pm »
This is a commonly asked question and I think it means you don't have the paths set in the IDE.

In Environment | Options, check that the paths are correct.

In Lazarus directory, I believe it should point to /Developer/lazarus assuming you didn't move this folder.

In FPC source directory, I believe it should point to /usr/local/share/fpcsrc. You can check to make sure you have this folder.

The other paths should be filled in too, but they probably aren't the reason for the message.

I'm not at my Mac, so I'm just trying to recall what these paths are. Try that and see if it helps any.

Thanks.

-Phil

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #3 on: November 04, 2009, 08:05:49 pm »
I have all these paths correct but I still get the error message

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Error Compiling in OSX Snow Leopard
« Reply #4 on: November 04, 2009, 08:08:24 pm »
You probably don't have it set up right.

Take a look at this for ideas of what might be wrong, although I find this entry a bit confusing:

http://wiki.lazarus.freepascal.org/Lazarus_Faq#.22Cannot_find_Unit_interfaces.22._How_can_I_solve_this.3F

Note this has nothing to do with OS X per se, just how you have your Lazarus/FPC installed.

Thanks.

-Phil

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #5 on: November 06, 2009, 02:20:36 am »
I re-installed all three packages and I was able to get my "Hello World" program compiled and running Ok. However, I am now trying to work on another project but everytime I try to save, the program aborts. This is weird.

If I try to save the unit using save or saveas, the program ends. If I try to save the project the same thing happens.

I have never ever have this happen to me before.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Error Compiling in OSX Snow Leopard
« Reply #6 on: November 06, 2009, 04:14:48 am »
I've never seen that happen either.

Please tell us about this "other project" that causes Lazarus to crash. Did you create it earlier and now can't save it? Or is it also a new project?

Make sure you're trying to save it to a folder where you have write privileges, for example under your home folder somewhere.

Does Lazarus give any error message? Check the OS X Console app.

Thanks.

-Phil

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #7 on: November 06, 2009, 02:47:23 pm »
It is a working program in delphi that I ported to lazarus. Using the Tools routines, I converted everything without any problem and everything got converted fine.

I was even able to install the functs component without a problem. However, I had a dusty time doing all of that because for reasons that I do not know, sometimes, the save or saveas or save project or save project as or Open, all terminate, kill, close the program. This will happen for some time and suddenly, they would work again.

I do not know what causes the problem to come on and what causes it to go away.

As if this was not enough, I now have another problem. Below is some sample code and an explanation of the problem.

type
TFuncts = Class(TComponent)

public
procedure breakapart(str: String; ch: Char; var sub: Array of String ; var num: Integer);

The above is the declaration of the procedure in Delphi. It is a Unit with a few very important procedures and functions that I made a component (Functs) with to help me in programming Delphi.

***************************************************************

Below is some of my code that I am using the procedure in,  in Lazarus.

procedure TTwoPointResection.Button4Click(Sender: TObject);
var
loaddata: TStrings;
x,indx: Integer;
filename,loadstring: String;
datastrings: Array[0.19] of String;

begin

loaddata := TStringlist.Create;
setlength(datastrings,20);

if opendialog1.Execute then
   filename := opendialog1.FileName
   else exit;

loaddata.LoadFromFile(filename);

for x := 1 to 4 do begin
    loadstring := loaddata.Strings[x-1];
    functs1.breakapart(loadstring,',',datastrings,indx);  
    ...
    ...
    ...
 **********************  
    
    
    
    When trying to compile, I get this error message when the compiler reaches this line [functs1.breakapart(loadstring,',',datastrings,indx);]
    
    "Got Dynamic Array of AnsiString" expected "Open array of ShortString" This is the only compiler error.
    
    
    Now this is a component that I have used many many many times in Delphi without any problems. It allows me to break up a string on any    character.

lazarus is giving me gray hairs.


Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: Error Compiling in OSX Snow Leopard
« Reply #8 on: November 06, 2009, 03:33:39 pm »
type
TFuncts = Class(TComponent)

public
procedure breakapart(str: String; ch: Char; var sub: Array of String ; var num: Integer);

The above is the declaration of the procedure in Delphi. It is a Unit with a few very important procedures and functions that I made a component (Functs) with to help me in programming Delphi.
[
***************************************************************

Below is some of my code that I am using the procedure in,  in Lazarus.

procedure TTwoPointResection.Button4Click(Sender: TObject);
var
loaddata: TStrings;
x,indx: Integer;
filename,loadstring: String;
datastrings: Array[0.19] of String;

begin

loaddata := TStringlist.Create;
setlength(datastrings,20);
The above code does not make sense to me. I guess datastrings is declared as "datastring: array of string", not as "datastring: array[0..19] of string". You can't set the length of a non-dynamic array.

Quote
   When trying to compile, I get this error message when the compiler reaches this line [functs1.breakapart(loadstring,',',datastrings,indx);]
    
    "Got Dynamic Array of AnsiString" expected "Open array of ShortString" This is the only compiler error.
    
    
    Now this is a component that I have used many many many times in Delphi without any problems. It allows me to break up a string on any    character.

If you want Delphi behaviour, then you have to compile your code in Delphi mode. In non-Delphi modes, string=shortstring (for backwards compatibility), in Delphi mode string=ansistring (for Delphi compatibility).

The error says exactly that: you are passing in a dynamic array of ansistrings (so the current file has at least one of {$mode delphi} or {$h+}), while the compiler expected an open array of shortstrings (so the unit with your utility functions has neither).

Be sure to use {$mode delphi} and not just {$h+}, since there are other differences between the default fpc mode and Delphi mode.

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #9 on: November 06, 2009, 06:38:26 pm »
Phil,

Thanks for that. I will try putting in the compiler code you suggest and see if my code compiles.
The setlength command is an error on my part and should have been removed. It is not in the code I compiled.

You did not address the more vexing problem however, the closing of the program when I press save, saveas, etc. as I explained in my previous post.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Error Compiling in OSX Snow Leopard
« Reply #10 on: November 06, 2009, 06:52:23 pm »
You did not address the more vexing problem however, the closing of the program when I press save, saveas, etc. as I explained in my previous post.
You did provide the necessary feedback, did you actually read How to ask questions the smart way?, as I suggested?

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #11 on: November 07, 2009, 12:14:43 am »
I have now read the "how to ask questions the smart way" post and
I apologize if I asked my question in a rude manner. I do not ever mean to offend or to be rude. I am just very excited about programming the Mac to run the many programs that I have already written in Delphi and I want to get started fast.

About the "save or save as" problem that I am experiencing.

I have searched this forum (Mac OSX) and there is no other topic concerning it.

All I can tell you is that I open Lazarus, then try to save the Unit1 and/or Project1 file but as soon as I hit save lazarus would close. Eventually, after many opening lazarus,hitting save and crashing, lazarus' save would work.

I have no clue as to what causes the problem or how to fix it.

I would be grateful if anyone on this forum can help.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Error Compiling in OSX Snow Leopard
« Reply #12 on: November 07, 2009, 03:20:36 am »
Again, where are you trying to save it? Post directory path here.

Thanks

-Phil

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Error Compiling in OSX Snow Leopard
« Reply #13 on: November 07, 2009, 09:58:38 am »
I have now read the "how to ask questions the smart way" post and
I apologize if I asked my question in a rude manner.[/qupte]
I don't think you asked your questions in a rude manner. You just give too little specific information.
Quote
I have no clue as to what causes the problem or how to fix it.

I would be grateful if anyone on this forum can help.
We have a hard time helping you because you don't give enough information for us to know the cause of the problem.

Try starting Lazarus in a Terminal as Phil suggested before and attach the output here.

earlcenac

  • New Member
  • *
  • Posts: 14
Re: Error Compiling in OSX Snow Leopard
« Reply #14 on: November 08, 2009, 02:46:59 am »
Here is the terminal output

Last login: Sat Nov  7 21:21:58 on ttys000
cecil-sylvesters-imac-3:~ Cecil$ cd /developer/lazarus
cecil-sylvesters-imac-3:lazarus Cecil$ open lazarus.app
cecil-sylvesters-imac-3:lazarus Cecil$

Lazarus opened Ok and again when I hit the Save menu item the program closed.

It seems to me that every command like Save, SaveAs, Open, etc that requires some sort of dialog to open, closes the program as soon as I hit it.

The save dialog or open dialog, etc does not display. The program crashes/closes instead.

 

TinyPortal © 2005-2018