Matthew said:
How would I go about creating a simple "hello world" program that will
run in UNIX. I am using MS Visual C++.
You've got a few answers, but not really the whole picture yet.
Box, Pete and Kop showed you how to write source code that's portable to
UNIX. Just use only the ANSI interface, like what Bjarne Stroustrup
describes in The C++ Programming Language, and you'll be good.
To do much else in UNIX, you'll need to use POSIX, which is an API that
most, if not all, UNIX systems support fully, so you should check it
out. Any good book that talks about UNIX programming will cover POSIX.
Example: Advanced Programming in the UNIX Environment, by W. R. Stevens.
That's how to write code for UNIX.
The next group is talking about cross compilers. A cross compiler
compiles on one type of system (example: Win 32) to a different type of
system (example: UNIX). I can't think of any cross compilers off the
top of my head. GCC (the GNU compiler) will do it, but it's very
complicated. If someone hasn't made and maintain binaries to do what
you want, it may not be worth it to try to do this yourself. The GCC
Cross-Copmile HOWTO is stale (old, out-of-date) and might not be of much
help.
The alternative is to use a library to do your dirty work for you. Wine
was mentioned (
www.winehq.org). This library emulates most (not all)
windows function calls, which allows you to run BINARY windows programs
on a UNIX system. I think it'll even run .exe files directly. Check it
out if this sounds like what you are after.
There are also libraries that allow UNIX programs to run on windows.
Cygwin (
www.cygwin.com) is free and gives you an environment for running
UNIX programs. Cygwin also gives you a full UNIX development
environment, so this maybe is something you should consider seriously.
Instead of tediously switching computers to test your UNIX programs, or
using a dual-boot setup, you could just run cygwin and test and develop
there, and learn something about UNIX itself at the same time. All this
without ever having to leave windows! Plus it's free. Definitely check
this out.
Also, MinGW (
www.mingw.org) is a free gcc compiler for windows. It only
gives you about 80% of the POSIX environment, but runs native UNIX
programs. It's better integrated into windows than Cygwin. And it can
even run UNIX configure scripts (with MSYS, available on the same site).
But it's not a full unix environment, just a gcc compiler for windows.
It's really designed for moving from UNIX to windows with GCC, not the
other way around. But it's still good so you might want to look at it.
Finally, the best way to go might just to get some neutral (neither
Win32 nor POSIX) library. This is the way to go if you're starting from
scratch (if you're porting a large existing code base, look into the
emulation libraries above). wxWindows (
www.wxwindows.com) is a portable
GUI library that gives you much more than just POSIX (no GUI in POSIX),
and is also portable to a large number of systems, win32, UNIX and
UNIX-like. There's also SDL (
www.libsdl.org) which is similar to
wxWindows but lighter weight and designed for media (games, etc.) type apps.
There you go!