ActiveState Powered by ActiveState

ActiveState Community


Creating an executable for Mac from Windows

Posted by relaxmike on 2008-02-29 13:41
OS: Windows

Hi,

I am working on my windows PC to cross-compile a Tcl program
to make it available on several systems, including
Windows, Linux and Mac. I was succesful with windows and
linux, but I am not able to do that for Mac.

The problem is that I use Tcl binary packages such as Img,
Tclx and tbcload.
I was able (after several days of hard and fun fight) to use TclApp
to make the win32 executable and to make the linux executable.
I did that following your recommandations, that is to say
that I unzipped the corresponding Active Tcl version for each
target platform, picking the binary packages that I needed and
gave them for TclApp to eat them : it made a crunch noise, but
it worked fine !
I tested both version and it works fine.
Sun, HP, etc... work the same way so I have no problem here.

My problem is that I cannot open the .dmg file corresponding
to the Mac ActiveTcl distribution (I usually use 7zip).

I tried to use dmg2iso executable, available here :
http://vu1tur.eu.org/tools/
but it failed :

(Atelier Tcl) 52 % exec dmg2img.exe ActiveTcl8.4.16.0.282109-macosx-universal-threaded.dmg ActiveTcl8.4.16.0.282109-macosx-universal-threaded.img
child killed: SIGABRT

(Atelier Tcl) 53 % exec dmg2iso.exe ActiveTcl8.4.16.0.282109-macosx-universal-threaded.dmg ActiveTcl8.4.16.0.282109-macosx-universal-threaded.iso
dmg2iso v0.2c by vu1tur (vu1tur@gmx.de)

reading property list...ok
found 4 partitions
decompressing:
partition 0...ok
partition 1...ERROR: Inflation failed

Is there another way to get the Mac versions of the binary packages
that I need ?

Thank you for your help !

Best regards,

Michaël

jeffh | Fri, 2008-02-29 14:53

TclApp is actually designed for cross-platform flexibility through the use of the TEApot. All you need is the basekit for the correct platform. Ideally you should use on that you know works for your application. You can retrieve one directly via the teapot, eg at this link:

http://teapot.activestate.com/application/name/base-tk-thread/ver/8.5.1....

Save that file as 'basekit-tk-8.5.1.1-thread-macosx-universal' (or something appropriately descriptive).

Use that as your basekit ("Prefix file") in TclApp. TclApp will recognize that it is for OS X. If your project file is working correctly, TclApp should try and download the binaries for OS X from teapot for the correct platform.

Note that this is a very advanced use case, so if it has issues, please let us know via the support at activestate email address.

relaxmike | Mon, 2008-03-03 14:53

Thank you very much for that tip.
But it did not work completely, so I have to make you scratch
your head you once again !

I used the graphical TclApp from a web-connected Windows PC.
I tuned the preferences to add

http://teapot.activestate.com

into the "TEAPOT Repositories".
I set the basekit to the file which was available from the
linked that you gave to me.
After unlocking the firewall because of TclApp accessing to the web,
the wrapping process went fine.
My script uses the packages Img, tbcload and Tclx.
This is the full report from TclApp :
******************************************

| Tcl Dev Kit TclApp
| Copyright (C) 2001-2008 ActiveState Software Inc. All rights reserved.
| Standard license for Micha�l Baudin .
|
| Embedding license information into wrap result as comments.
|
Command line:
C:/TclDevKit4.0.2/bin/tclapp.exe -prefix D:/Atelier/AtelierTcl/StarPackMac/SampleForMac/base-tk-thread-8.4.18-macosx-universal.exe -out D:/Atelier/AtelierTcl/StarPackMac/SampleForMac/sample-mac.exe -architecture macosx-universal -pkgref Img -pkgref Tcl -pkgref Tclx -pkgref Tk -pkgref 'tbcload 1.7' -relativeto D:/Atelier/AtelierTcl/StarPackMac D:/Atelier/AtelierTcl/StarPackMac/SampleForMac/main.tcl -startup lib/application/SampleForMac/main.tcl
Wrapping ...
No known repository at C:/tap_help_repository
Expanding...
Following only profile dependencies
Accepting missing dependencies
Accepting version changes made by fuzzy search

P package Tcl 8.4 macosx-universal ...
P package Tk 8.4 macosx-universal ...
P package Tk 8.4 tcl ...

Issues...

Packages ...
Img 1.3 tcl @ R http://teapot.activestate.com
P Tcl 8.4 macosx-universal @
Tclx 8.4 macosx-universal @ R http://teapot.activestate.com
P Tk 8.4 macosx-universal @
P Tk 8.4 tcl @
tbcload 1.7 macosx-universal @ R http://teapot.activestate.com

Inserting TEApot metadata
Nothing to insert

tbcload 1.7 (macosx-universal)
Tclx 8.4 (macosx-universal)
Img 1.3 (tcl)
Extending the list of provided packages

F 117B D:/Atelier/AtelierTcl/StarPackMac/SampleForMac/main.tcl

Generated D:/Atelier/AtelierTcl/StarPackMac/SampleForMac/sample-mac.exe
Done

| Embedded license information into wrap result as comments.
| Standard license for Micha�l Baudin .
******************************************

I looked inside the executable with TclApp to check that
the packages were correctly installed : it did not...
The packages tbcload and Tclx8.4 were fine, as far as I can see
from the presence of the *.dylib files.
But the Img package contained only two files :
- pkgIndex.tcl
- implementation.tcl
which does not match the list of files that I expect to
see : tkimg*.dylib files are not there.

The content of the "implementation.tcl" file is :

*****************************************
# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*-
# -- Tcl Module

# ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS

package require Tcl 8.4
package require Tk 8.4
package require img::bmp 1.3-2
package require img::gif 1.3-2
package require img::ico 1.3-2
package require img::jpeg 1.3-2
package require img::pcx 1.3-2
package require img::pixmap 1.3-2
package require img::png 1.3-2
package require img::ppm 1.3-2
package require img::ps 1.3-2
package require img::sgi 1.3-2
package require img::sun 1.3-2
package require img::tga 1.3-2
package require img::tiff 1.3-2
package require img::window 1.3-2
package require img::xbm 1.3-2
package require img::xpm 1.3-2

# ACTIVESTATE TEAPOT-PKG END REQUIREMENTS

# ACTIVESTATE TEAPOT-PKG BEGIN DECLARE

package provide Img 1.3

# ACTIVESTATE TEAPOT-PKG END DECLARE
# ACTIVESTATE TEAPOT-PKG END TM

# Compatibility hack. When asking for the old name of the package
# then load all format handlers and base libraries provided by tkImg.
# Actually we ask only for the format handlers, the required base
# packages will be loaded automatically through the usual package
# mechanism.

# When reading images without specifying it's format (option -format),
# the available formats are tried in reversed order as listed here.
# Therefore file formats with some "magic" identifier, which can be
# recognized safely, should be added at the end of this list.

package require img::window
package require img::tga
package require img::ico
package require img::pcx
package require img::sgi
package require img::sun
package require img::xbm
package require img::xpm
package require img::ps
package require img::jpeg
package require img::png
package require img::tiff
package require img::bmp
package require img::ppm
package require img::gif
package require img::pixmap

package provide Img 1.3
************************************************

I think that this may be connected to the previous bug
(see my previous post in the TDK support forum) that I
had for the particular Img package.

So I tried to use the command-line "teacup.exe" tool
to manually get the mac version of the Img package,
and I runned into more trouble.
It seems that the client locks the installation of
one package if the current architecture does not match
the required one :

(StarPackMac) 73 % teacup install --arch macosx-universal img::base 1.3
The requested architecture "macosx-universal" is not supported
by the repository at
"D:/Atelier/AtelierTcl/StarPackMac/Repository/".

This is wise in the general case, but my current problem
is specifically to make the executable on a system which I do
not have. I tried the "--force" option, which did not help.

Thank you for your help !

Best regards,

Michaël

PS-1
In fact, making the linux and unix based executable was really
so easy that I did not think that I used "advanced" features...

PS-2
I had to solve a problem linked with the Tclx package, and
that is worth to mention, if anybody has the same problem.
In an automatically wrapped executable, the Tclx8.4 package
cannot be found : I think I got the reason for that.
When wrapping the application, TclApp creates the directories
associated with the required packages on the target platform.
For example, for the Tclx package and Mac, it creates
the directory :

P-macosx-universal-Tclx-8.4

The problem appears with the Tclx package when the following line
in the pkgIndex.tcl file of the Tclx package :

load [file join {@} libtclx8.4.dylib] Tclx

is triggered. The process inside the library searches for
a sub-directory name "Tclx8.4" in one directory
from the ::auto_path variable. When it comes to the target directory,
it instead searches for a

P-macosx-universal-Tclx-8.4/Tclx8.4

directory, which of course does not exist ! The consequence is that
the package Tclx8.4 is not found and generates an error.
I don't think that the problem here is because of TclApp, which does
its job perfectly, but the problem is more on the side
of Tclx, because it makes no use of the "$dir" local variable
which is passed automatically with the "package require" system.

AndreasK | Mon, 2008-03-03 16:05

Img:

Use the -follow command line options to have TclApp follow the dependencies of Img.

Or: Explicitly add -pkgref img::base -pkgref img::bmp ... etc. to the command line.

Both will cause TclApp to pull the packages from teapot.activestate.com

Installing into the local repository is not required for this.

TclX:

That is ... bad. IIRC Tclx uses the tcl_findLibrary command to locate its init.tcl file from within the shared library ... That command could very well have this limitation that it needs the Tclx8.4 directory :(

A workaround would be to add

set env(TCLX_LIBRARY) [file join [file dirname [info script]] lib P-macosx-universal-Tclx-8.4]

to the initialization code (See panel 'Advanced').

The proper fix would be to modify Tclx to not use tcl_findLibrary any more, but explicitly source its init.tcl file from its 'package ifneeded' script.

That is something we will have to do.

relaxmike | Wed, 2008-03-05 03:40

Thank you for your answer.

Img :
The "-follow" option did not solve the problem.
Instead, the other option of explicitely adding the
packages to the list worked fine.
I modified the .tpj so that it contained the lines :

Pkg/Reference img::window
Pkg/Reference img::tga
Pkg/Reference img::ico
Pkg/Reference img::pcx
Pkg/Reference img::sgi
Pkg/Reference img::sun
Pkg/Reference img::xbm
Pkg/Reference img::xpm
Pkg/Reference img::ps
Pkg/Reference img::jpeg
Pkg/Reference img::png
Pkg/Reference img::tiff
Pkg/Reference img::bmp
Pkg/Reference img::ppm
Pkg/Reference img::gif
Pkg/Reference img::pixmap
Pkg/Reference zlibtcl
Pkg/Reference pngtcl
Pkg/Reference tifftcl
Pkg/Reference jpegtcl
Pkg/Reference img::base

At it worked, by creating one directory for each package.
Now I will be able to expand the executable
and pick each .dylib so that I can re-create a full Img package, Mac ready.
This is because the computer on which I create the release is
offline, so that I cannot use the default online Tea system.

That workaround will work, but it is clearly made complicated because
of that limitation of TclApp.

Considering the Tclx problem, I submitted the bug to the
sourceforge Tclx project.

Thank you for your help !

Best regards,

Michaël

-->