Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-02

building universal binary

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ken G. Brown

Mac OS X 10.5.6, fpc 2.2.2, Xcode 3.1.2

Have a Pascal program calling some C code from a static library I build in a separate project so I can use the debugger.

I've set Xcode to use gcc 4.0 targeting 10.4 for intel, and gcc 3.3 targetting 10.3.9 for PowerPC in both projects.

So far I am basically using the fpc user defined options that came with the template for building for calling C functions.

Do I need to add some fpc options in order to properly compile for a universal binary?

I looked at my App using lipo -info fromTerminal and get the following error: lipo: Can't map input file: .../myapp/build/Release/myapp.app ((os/kern) invalid argument)

As well, in Finder Get Info for my app, the 'open using Rosetta checkbox is greyed out and I cannot select it. Activity Monitor of course shows an intel program but i need to deploy to PowerPC running 10.3.9.

If I look at my 'C' library project product with lipo, I get Architectures in the fat file: ...../libkbCarbonLib.a are: i386 ppc

What else do I need to do in order to generate a universal binary? Do I need to run the fpc ppc version somehow for the ppc side of tings? I suspect so but cannot find what to do.

Any tips appreciated.

Thx,
Ken G. Brown

Jonas Maebe
to Ken G. Brown
Ken G. Brown wrote
Have a Pascal program calling some C code from a static library I build in a separate project so I can use the debugger.

You can also build it in a separate target of the same project and then change the target-specific flags for that C library (as in the "FPC-C-C++ Carbon Application 2.2.0" template).

I looked at my App using lipo -info fromTerminal and get the following error: lipo: Can't map input file: .../myapp/build/Release/myapp.app ((os/ kern) invalid argument)

myapp.app is a folder (or more specifically, a bundle). The actual program is .../myapp/build/Release/myapp.app/Contents/MacOS/myapp

Show quoted text 11 lines
As well, in Finder Get Info for my app, the 'open using Rosetta checkbox is greyed out and I cannot select it. Activity Monitor of course shows an intel program but i need to deploy to PowerPC running 10.3.9. If I look at my 'C' library project product with lipo, I get Architectures in the fat file: ...../libkbCarbonLib.a are: i386 ppc What else do I need to do in order to generate a universal binary? Do I need to run the fpc ppc version somehow for the ppc side of tings? I suspect so but cannot find what to do.

You have to go to the project's build settings for the configuration that you are building (presumably "release"), and then set the "Architectures" setting (the second from the top) to "Standard (32-bit Universal)". This works at least for me with the "FPC-C-C++ Carbon Application 2.2.0" template.

Jonas

Ken G. Brown
to Ken G. Brown: Mac OS X 10.5.6, fpc 2.2.2, Xcode 3.1.2 Have a Pascal program calling some C code from a…

Further:
it appears that lipo cannot handle app bundles, so if I run it on the executable itself, it says it is ok, has both i386 and ppc. So I guess I'm missing something that tells Finder it is a universal binary, but what?

Thx,
Ken G. Brown

Ken G. Brown apparently wrote 23 lines
Mac OS X 10.5.6, fpc 2.2.2, Xcode 3.1.2 Have a Pascal program calling some C code from a static library I build in a separate project so I can use the debugger. I've set Xcode to use gcc 4.0 targeting 10.4 for intel, and gcc 3.3 targetting 10.3.9 for PowerPC in both projects. So far I am basically using the fpc user defined options that came with the template for building for calling C functions. Do I need to add some fpc options in order to properly compile for a universal binary? I looked at my App using lipo -info fromTerminal and get the following error: lipo: Can't map input file: .../myapp/build/Release/myapp.app ((os/kern) invalid argument) As well, in Finder Get Info for my app, the 'open using Rosetta checkbox is greyed out and I cannot select it. Activity Monitor of course shows an intel program but i need to deploy to PowerPC running 10.3.9. If I look at my 'C' library project product with lipo, I get Architectures in the fat file: ...../libkbCarbonLib.a are: i386 ppc What else do I need to do in order to generate a universal binary? Do I need to run the fpc ppc version somehow for the ppc side of tings? I suspect so but cannot find what to do. Any tips appreciated. Thx, Ken G. Brown
Ken G. Brown
Show quoted text 6 lines
> Have a Pascal program calling some C code from a static library I > build in a separate project so I can use the debugger. You can also build it in a separate target of the same project and then change the target-specific flags for that C library (as in the "FPC-C-C++ Carbon Application 2.2.0" template).

Does this method still allow running gdb on the C code?

Show quoted text 7 lines
> I looked at my App using lipo -info fromTerminal and get the > following error: > lipo: Can't map input file: .../myapp/build/Release/myapp.app ((os/ > kern) invalid argument) myapp.app is a folder (or more specifically, a bundle). The actual program is .../myapp/build/Release/myapp.app/Contents/MacOS/myapp

Yep, finally figured that out.

> As well, in Finder Get Info for my app, the 'open using Rosetta > checkbox is greyed out and I cannot select it. Activity Monitor of > course shows an intel program but i need to deploy to PowerPC > running 10.3.9.

Now my latest build appears to allow running under Rosetta, but incorrectly.

Show quoted text 13 lines
> If I look at my 'C' library project product with lipo, I get > Architectures in the fat file: ...../libkbCarbonLib.a are: i386 ppc > > What else do I need to do in order to generate a universal binary? > Do I need to run the fpc ppc version somehow for the ppc side of > tings? I suspect so but cannot find what to do. You have to go to the project's build settings for the configuration that you are building (presumably "release"), and then set the "Architectures" setting (the second from the top) to "Standard (32-bit Universal)". This works at least for me with the "FPC-C-C++ Carbon Application 2.2.0" template.

Yes is working now for me too, not sure what i did at this point to make it happen.

Thx

Jonas
Jonas Maebe
to Ken G. Brown
Ken G. Brown wrote 8 lines
>> Have a Pascal program calling some C code from a static library I >> build in a separate project so I can use the debugger. > > You can also build it in a separate target of the same project and > then change the target-specific flags for that C library (as in the > "FPC-C-C++ Carbon Application 2.2.0" template). Does this method still allow running gdb on the C code?

Yes. When you have separate targets, you can set separate options for the different targets (so you can turn on gcc debugging info for the library target and disable it for the FPC target).

Jonas

Ken G. Brown
apparently wrote 25 lines
Date: Wed, 4 Feb 2009 10:50:17 +0100 From: Jonas Maebe Subject: Re: [fpc-pascal] Re: building universal binary To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On 03 Feb 2009, at 23:33, Ken G. Brown wrote: >>> Have a Pascal program calling some C code from a static library I >>> build in a separate project so I can use the debugger. >> >> You can also build it in a separate target of the same project and >> then change the target-specific flags for that C library (as in the >> "FPC-C-C++ Carbon Application 2.2.0" template). > > Does this method still allow running gdb on the C code? Yes. When you have separate targets, you can set separate options for the different targets (so you can turn on gcc debugging info for the library target and disable it for the FPC target). Jonas

So far I'm still in two projects but I'll try this method later, it will be easier I think. Don't want to change too many things right now.

Now everything seems pretty good, have universal bninary, building both debug and release versions, both run as desired under Xcode control.

Program formats output and sends directly to a serial port to a tractor feed printer.

However, when I try running from Finder, I get a short few characters out the serial port then the program dies. This is whether or not the 'run under Rosetta' box is checked in Get Info. Intel or PowerPC shows properly in Activity Monitor. I've tried inserting printf in the 'C' code just before the write statement but cannot find any output. Also tried fprintf's to stdout and stderr. I've tried running the program from Terminal to see if that helped. How and where should I be able to see output? Where should a write(var); go from the pascal side?

Debug print stuff shows up to the console when running under Xcode.

What should I look for that would cause it to work fine from Xcode but die from Finder?

MacOS 10.5.6, fpc 2.2.2, Xcode 3.1.2

Info.plist looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>PrintSmallOSX</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.PrintSmallOSX</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PrintSmallOSX</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
</dict>
</plist>

Thx for any tips,
Ken G. Brown

Jonas Maebe
to Ken G. Brown
Ken G. Brown wrote 9 lines
However, when I try running from Finder, I get a short few characters out the serial port then the program dies. This is whether or not the 'run under Rosetta' box is checked in Get Info. Intel or PowerPC shows properly in Activity Monitor. I've tried inserting printf in the 'C' code just before the write statement but cannot find any output. Also tried fprintf's to stdout and stderr. I've tried running the program from Terminal to see if that helped. How and where should I be able to see output? Where should a write(var); go from the pascal side?

For GUI apps, it will go to the console. Open /Applications/Utilities/ Console.app to see it.

Jonas

Ken G. Brown
to Jonas Maebe
Jonas Maebe apparently wrote 5 lines
On 04 Feb 2009, at 18:48, Ken G. Brown wrote: >However, when I try running from Finder, I get a short few characters out the serial port then the program dies. This is whether or not the 'run under Rosetta' box is checked in Get Info. Intel or PowerPC shows properly in Activity Monitor. I've tried inserting printf in the 'C' code just before the write statement but cannot find any output. Also tried fprintf's to stdout and stderr. I've tried running the program from Terminal to see if that helped. How and where should I be able to see output? Where should a write(var); go from the pascal side? For GUI apps, it will go to the console. Open /Applications/Utilities/Console.app to see it.

Wasn't having any luck seeing it there either. I'm bring some legacy code forward, perhaps I'm missing some sort of startup code.

Thx,
Ken

Show quoted text 5 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Ken G. Brown
Ken G. Brown wrote 18 lines
At 10:30 PM +0100 2/4/09, Jonas Maebe apparently wrote: > On 04 Feb 2009, at 18:48, Ken G. Brown wrote: > >> However, when I try running from Finder, I get a short few >> characters out the serial port then the program dies. This is >> whether or not the 'run under Rosetta' box is checked in Get Info. >> Intel or PowerPC shows properly in Activity Monitor. I've tried >> inserting printf in the 'C' code just before the write statement >> but cannot find any output. Also tried fprintf's to stdout and >> stderr. I've tried running the program from Terminal to see if >> that helped. How and where should I be able to see output? Where >> should a write(var); go from the pascal side? > > For GUI apps, it will go to the console. Open /Applications/ > Utilities/Console.app to see it. Wasn't having any luck seeing it there either. I'm bring some legacy code forward, perhaps I'm missing some sort of startup code.

No special startup code is necessary for either the C library or for the FPC run time library (at least not under Mac OS X with the Xcode templates).

Jonas