Compiling on Win95 and Running on the Mac with Codewarrior
Last updated May 31th, 1997
Helpful tools for Win95
Helpful tools for the Mac
How to Compile "Hello World" on the PC and run on the Mac
- Create a new project with "File / New Project / Mac OS / C,C++ / C,C++ PPC".
Put the new project in c:\HELLO.
This inserts HelloWorld.c into the new project by default.
- Change the default name of the executable from "Hello World PPC"
to MacHello to make it easier to transfer. You do this by selecting
"Edit / Project Settings / PPC Project", and changing
File Name under Application Info.
- Click on "Make" (the little app icon third from the right)
(Compiling isn't good enough; you need to Make to get it to link.)
- You should now have an executable file named C:\HELLO\MacHello;
its resource fork is named C:\HELLO\resource.frk\MacHello.
- Transfer the executable and its resource fork to the Mac.
-
Make sure your PCExchange control panel is enabled, so your Mac can
read and write PC floppies.
-
Put a blank PC floppy in the PC's drive.
-
xcopy c:\hello a:\ /s
This is a cheezy way of copying MacHello and resource.frk/MacHello.
-
Move the floppy to the Mac, and drag the MACHELLO icon only to
a folder on the mac. (Don't drag it onto the desktop; this wouldn't
force a copy.)
- Set the FileType to APPL and the creator to ???? using ResEdit.
- Double-click it.
Other ways to transfer the executable to the Mac
Beyond the simple floppy-and-PCExchange method, there are:
-
Run NetPresenz on the Mac, and use FTP to put
the data fork (C:\HELLO\MacHello) and the resource fork
(C:\HELLO\resource.frk\MacHello) into the proper place
on the Mac (i.e. the resource and data forks of a single file MacHello).
Normal FTP clients don't know how
to send resource forks, so you should
use MetroWerks' SendMacApp program, which
knows how to package up both the data and resource forks
into MacBinary format, which NetPresenz understands.
need example here
- Create a .tar archive on the Mac using SUNTAR; this automagically
converts each forked file to MacBinary format before archiving.
You can then unpack that file on a Unix or Win95 system, operate
on the files (e.g. check them in to a version control system),
repack them with a normal tar program, and transfer them back to
the Mac; SUNTAR will decode the MacBinary wrapper when unpacking the
archive.
- Share a volume between the Mac and the Win95 system,
using some Mac-aware networking software like MacLan for Windows 95.
Where is conio.h? How do I implement kbhit() and getch()?
Ron Liechty of Metrowerks answers this question periodically
on comp.sys.mac.programmer.codewarrior.
Here's his code, wrapped up into a tidy package:
I renamed my file on the PC, and when I transfer it over to the Mac, it has the old name. HELP!
MacBinary appears to store the filename inside its header!
You can't rename files when they are in MacBinary format; you have
to rename them on the Mac, then wrap them in MacBinary again.
The compiler on the Mac can't find a file which I can see is there!
-
Make sure the file has a text type of some sort. PC Exchange files
are recognized by the IDE but not the compiler! Files
unpacked by Suntar are recognized properly because Suntar gives
them a generic 'text document' type.
-
Make sure there aren't any hidden nonspacing characters in the
filename. Something (maybe the IDE?) puts one or two at the end
or before the suffix sometimes. You can tell by clicking on
the filename in the Finder as if you were renaming it, then use
the arrow keys to move from one end of the name to the other; if
you have to press the arrow key twice or three times to get the
cursor to move, you've found an invisible character. Backspace over
it, and all should be well.
-
Make sure your access paths are set up correctly (in Edit / Project Settings).
Other Sources of Mac Programming Info
Dan Kegel
With help from Ron Liechty and Jeremy Leader