* * *

Author Topic: RichMemo on Cocoa not compiling  (Read 586 times)

dbannon

  • New member
  • *
  • Posts: 47
RichMemo on Cocoa not compiling
« on: September 12, 2017, 02:52:04 pm »
I have been working on an ap based around RichMemo. Just tried it on a Mac. As expected, Carbon does not do what I need and the chart on the Wiki indicates a lot more does work with Cocoa. So switched (Project->ProjectOptions->ConfigAndTarget) to Cocoa.

Initially failed Line 532 CocaRichMemo.pas with "identifier not found taLeft"
AStopList.Tabs[ i].Align:=taLeft;

So I commented that out, not needing any tab stuff. But then I get told the following units in Uses clause of  CarbonRichMemo.pas (Line 35 and 36) "CarbonDef, CarbonUtils, CarbonProc, CarbonEdits Cannot be found".

I cannot find taLeft or units mentioned above in the RichMemo Package.

Surprising because it did all compile when I was using Carbon. Sigh ...

Do I need do more to switch over to Cocoa ?

Should I expect it to compile ?

I am using Lazarus 1.8rc4 and OSX Sierra. Testing with a small bit of code that works fine on Linux and Windows.

David

Phil

  • Hero Member
  • *****
  • Posts: 2279
Re: RichMemo on Cocoa not compiling
« Reply #1 on: September 12, 2017, 03:38:34 pm »
Initially failed Line 532 CocaRichMemo.pas with "identifier not found taLeft"
AStopList.Tabs[ i].Align:=taLeft;

Typo. Should be tabLeft. Not sure how this non-compiling source got committed.

So I commented that out, not needing any tab stuff. But then I get told the following units in Uses clause of  CarbonRichMemo.pas (Line 35 and 36) "CarbonDef, CarbonUtils, CarbonProc, CarbonEdits Cannot be found".

Not sure what's going on here. Looks like Lazarus is trying to compile it both for Cocoa and Carbon (CarbonDef, etc. are Carbon LCL units needed by CarbonRichMemo).

I would only use Cocoa with Lazarus LCL trunk. The 1.8 RC4 Cocoa source is now over 5 months old and many improvements have been made to trunk Cocoa source that are not and will not be in 1.8.x. Here are some notes I wrote up (you can skip steps 4 and 5 if you're not interested in TWebBrowser control):

https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #2 on: September 13, 2017, 02:24:59 am »
Thanks Phil.
To simplify, I tried installing the package with Cocoa selected instead of Carbon. And I get those errors then, during the package install. Installs fine with Carbon.

Its clearly a problem in the package and only relates to Cocoa.

I'll have a read of your link and perhaps try doing the same thing under trunk although it does look like a RichMemo thing from where I sit. Yeah, but maybe the package author also uses trunk ? that would make sense....

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #3 on: September 13, 2017, 04:00:51 am »
Hmm, Phil, I tried your recipe, interesting.

Firstly, I cannot build anything in 1.9 because the toolbar that displays (eg) the components is not quite visible. I can see just the top of it and cannot pull its window down to see more.

So I tried your trick of using lazbuild to build RichMemo, that worked, I had to fix the taLeft thing but missing units did not crop up. I can then install it in my 1.8rc4. The ProjectOptions says I am using Cocoa but I don't see any improvement in RichMemo's functioning. Indeed, it now crashes. I have a list of things that I have found need patching, http://wiki.freepascal.org/RichMemo/WorkArounds and I'll add those back in and try again.

But right now, I need do something else...

Thanks for you advise, cool way to work.

David



 

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #4 on: September 14, 2017, 02:40:42 am »
OK, summary of where I am. Honestly, its not a great place !

With Phil's encouragment, I built the trunk, 1.9 version because it apparently has better Cocoa support. The Lazarus GUI is not usable, Component Tool Bar obscured and unclickable and there is no top menu. So not possible to run even an empty form as I need access to Options to setup gdb. See attached.

Should I log these problems ?  I note GillesH was having same problem with 1.9 back in July and I have had no response to RichMemo issues (and proposed fixes) that I logged several weeks ago.

But Phil was suggesting I could build RichMemo from the 1.9 (commandline) tools and install that into my existing 1.8rc4. And, initially it looked like that worked. It did get around the errors building RichMemo for Cocoa in 1.8rc4 at least.

However, I am convinced that I am not using the Cocoa widget set. 

If I set Options to Carbon, I can follow the code down to Units clearly labeled Carbon-something. But with Cocoa, no Cocoa branded code is called and the Widgets still look like Carbon. I loose some specific Carbon behavior but do not gain any specific Cocoa behavior.

I cannot find anything on the wiki about how to tell the difference between Carbon and Cocoa, either visually or from within the code. In fact, Cocoa hardly gets a mention on the wiki, leaving me to assume I am wasting my time. Please tell me otherwise.
 

Phil

  • Hero Member
  • *****
  • Posts: 2279
Re: RichMemo on Cocoa not compiling
« Reply #5 on: September 14, 2017, 03:30:10 am »
I cannot find anything on the wiki about how to tell the difference between Carbon and Cocoa, either visually or from within the code. In fact, Cocoa hardly gets a mention on the wiki, leaving me to assume I am wasting my time. Please tell me otherwise.

Compile for 64-bit. If that succeeds, then you're using Cocoa.

Also, look at the project's .compiled file. That will tell you what widgetset you compiled for and all other options.

Bugs should be reported in the bugtracker at left. Reporting them anywhere else will probably go unnoticed.

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #6 on: September 14, 2017, 06:21:46 am »
Thanks Phil, good answer, I'll check.

Hmm, file command says : "project1: Mach-O executable i386", sounds like 32 bit to me.

ProjectOptions..ConfigAndTarget->TargetCPUfamily changed from "default" to "x86_64". Big build after that, see cocoa units included in Messages. Good. However, same result. Executable is still i386 and that still sounds like 32bit.

But, the .compiled file ? cat lib/x86_64-darwin/project1.compiled ?
Has several mentions of x86_64-darwin and cocoa, thats certain. So, unless the compiler is somehow choosing to ignore all the switches its given, that binary must be 64bit and is Cocoa. Similarly, the 32bit ones I made previously, certainly mention Cocoa and not Carbon.

Thanks for that certainty Phil.

I suppose I have to assume that RichMemo is the problem. I am pretty sure the Cocoa versions of its functions are not being called. I'll have to find out why.

I'll log something about the 1.9 IDE's shy tool bars and menus.

Phil, really do appreciate your advice here !

David







Phil

  • Hero Member
  • *****
  • Posts: 2279
Re: RichMemo on Cocoa not compiling
« Reply #7 on: September 14, 2017, 03:04:17 pm »
Hmm, file command says : "project1: Mach-O executable i386", sounds like 32 bit to me.

That's 32-bit. To compile for 64-bit, you have to specify a 64-bit compiler.

See step 7.

https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #8 on: September 15, 2017, 02:19:54 am »
Ah, that makes sense.

I am convinced even the 32 bit version I have been making is Cocoa now however. Turns out the functions I initially traced are not implemented in Cocoa but further tracing did infact take me to some Cocoa units.

But to be sure, I set the 64bit compiler (Tools->Env->Files->Compiler Executable) to /usr/local/bin/ppcx64 and yep, I did get a 64bit executable. "project1: Mach-O 64-bit executable x86_64". But same problems....

Seems that RichMemo's Cocoa implementation is not quite what is described on the wiki. Further research is indicated ....

Thanks for you help Phil, you have taught me heaps !

(Hope you don't mind me recording some of that stuff on the wiki, might be obvious to you but not to a mac newbie like me!)

dbannon

  • New member
  • *
  • Posts: 47
Re: RichMemo on Cocoa not compiling
« Reply #9 on: September 17, 2017, 02:45:21 am »
OK, replying to myself (again).

No, sorry Phil, even this somewhat clever approach gets us nowhere.

The simplest app, drop a TMemo on an otherwise blank form, set options to Cocoa. Save.
Then from command line -

../../laz-svn/lazbuild --pcp=~/.laz-svn --ws=cocoa --compiler=/usr/local/bin/ppcx64 --cpu=x86_64 project1.lpi

Compiles cleanly but crashes under lldb during startup.

thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x4c)
    frame #0: 0xa0ccbf6f libobjc.A.dylib`default_throw(objc_object*) + 106
libobjc.A.dylib`default_throw:

Some things do work, a button on that form can, for example write to a Edit1.text. My app, based on RichMemo (descendant of Tmemo ?) fails to pass on the TRichMemo.OnChange event. And crashes during some file i/o that refreshes a TGrid. Don't know enough about lldb to find out where.

But I think I do know enough to know I am on the wrong track ...

Does the official status of Cocoa being "unstable" mean I should not report that simple test ? 

David

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus