By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,199 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,199 IT Pros & Developers. It's quick & easy.

Is C portable from PC to UNIX

P: n/a
Can I compile C source in an PC editor like Miracle, build it, and then
take that .exe over to Unix and run it there?
Is there a preferred group for beginners such as myself to join?

Jan 31 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a

emmitsuks wrote:
Can I compile C source in an PC editor like Miracle, build it, and then
take that .exe over to Unix and run it there?

If you use a cross-compiler and build for the target machine, then yes.
However, an executable built *for* Windows on x86 will not run
natively on Unix, especially if that Unix is running on different
hardware (PPC, MIPS, PA-RISC, Sparc, etc.).

Is there a preferred group for beginners such as myself to join?


If your questions are about the C *language*, then this is as good a
group as any (just have some asbestos underwear handy).

Jan 31 '06 #2

P: n/a
In article <11*********************@g44g2000cwa.googlegroups. com>,
John Bode <jo*******@my-deja.com> wrote:
emmitsuks wrote:
Can I compile C source in an PC editor like Miracle, build it, and then
take that .exe over to Unix and run it there?
If you use a cross-compiler and build for the target machine, then yes.
However, an executable built *for* Windows on x86 will not run
natively on Unix, especially if that Unix is running on different
hardware (PPC, MIPS, PA-RISC, Sparc, etc.).


<OT>

Though if you happen to want to run the Windows x86 code on an x86
based machine running any of several Unices or Unix-like systems
such as Linux, then there are free and commercial programs that
apparently do fairly good jobs of running the code. For non-x86
systems there are virtual machines or emulators available that
can run the x86 Windows code... possibly slowly.

One option to consider is to do the development on Windows but using
a Unix emulation library such as MingW or AT&T's UWIN; once that code
was working, taking the -source- to a Unix system and rebuilding would
usually be within a reasonable amount of work. But there are quite
a few flavour of Unix, so sometimes it does turn out to be a lot of
work, depending exactly what you are doing.

You can reduce the amount of work required to "port" a program
from Windows to Unix, by restricting yourself to the facilities provided
by the C language, and avoiding graphics, GUIs, networking, or
anything that needs to know about the "inside" of how the system
does its work. This newsgroup, comp.lang.c, often has discussions
about what is or is not part of the C language, so it is a good place
to visit if you want to write programs that are intended to be as
portable as practical.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Jan 31 '06 #3

P: n/a
thanks, I guess I should start trying to familiarize myself with an
editor on Unix like nano or vi instead of miracle or visual c

Jan 31 '06 #4

P: n/a
emmitsuks wrote:
Can I compile C source in an PC editor like Miracle,
Compilers may come with editors, but an editor is not a compiler.
build it, and then take that .exe over to Unix and run it there?
Generally no, not unless you're running a PC emulator on the Unix box.
Is there a preferred group for beginners such as myself to join?


You could try alt.comp.lang.learn.c-c++, but be sure to read the FAQ
before posting questions. Also realise that NO forum is good for
teaching you a language from the basics. Forums can help clarify
specific doubts on specific issues, but there are much better
structured tutorials that can help you learn C as a whole.

--
Peter

Jan 31 '06 #5

P: n/a
On Tue, 31 Jan 2006 21:11:45 +0000, Walter Roberson wrote:

You can reduce the amount of work required to "port" a program from
Windows to Unix, by restricting yourself to the facilities provided by the
C language, and avoiding graphics, GUIs, networking, or anything that
needs to know about the "inside" of how the system does its work. This
newsgroup, comp.lang.c, often has discussions about what is or is not part
of the C language, so it is a good place to visit if you want to write
programs that are intended to be as portable as practical.

If GUI is important the use a portable graphics library like qt, gtk or
wxwidgets.

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/p...rch=0xE3E80917

Feb 1 '06 #6

P: n/a
emmitsuks wrote:

thanks, I guess I should start trying to familiarize myself with
an editor on Unix like nano or vi instead of miracle or visual c


VIM and EMACS have been ported everywhere. If you settle on one of
those you will not need to change any habits when moving between
systems.

--
"The power of the Executive to cast a man into prison without
formulating any charge known to the law, and particularly to
deny him the judgement of his peers, is in the highest degree
odious and is the foundation of all totalitarian government
whether Nazi or Communist." -- W. Churchill, Nov 21, 1943

Feb 1 '06 #7

P: n/a
CBFalconer wrote:
emmitsuks wrote:
thanks, I guess I should start trying to familiarize myself with
an editor on Unix like nano or vi instead of miracle or visual c

VIM and EMACS have been ported everywhere. If you settle on one of
those you will not need to change any habits when moving between
systems.

....or between programming languages.
August

--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.
Feb 1 '06 #8

P: n/a
In article <43***************@yahoo.com>,
CBFalconer <cb********@maineline.net> wrote:
VIM and EMACS have been ported everywhere. If you settle on one of
those you will not need to change any habits when moving between
systems.


Dah. The Mars lander was lost because in the heat of the moment,
someone confused META-X and CONTROL-X before "deploy-parachute".
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Feb 1 '06 #9

P: n/a
emmitsuks wrote:
thanks, I guess I should start trying to familiarize myself with an
editor on Unix like nano or vi instead of miracle or visual c

Please red this: http://cfaj.freeshell.org/google/
If you want to spend time on this group you should learn some
things about how to write things on the group.

Now, I think it's good to learn how a program is put together. IDEs
like Visual C++, KDevelop and others are hiding things from you,
things that, I think, you should know about. I wouldn't use nano
but I would use a programmer's editor like vi or emacs. Given the
fact that these are source files, you can use whatever text editor you
want. Just remember, word is not a text editor :-).

If you are interested in portable applications then you might want
to know that compiled software written in C is not usually portable
across platforms. Code written specifically for Windows (using
GUI, or Windows API, in general) is even less portable.
If you want something that let's you have portable source across
quite a lot of operating systems and use C then you should take
a look at gtk+. If you are just a C beginner I would sugest to forget
all about graphics and stuff like that and learn to master C.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Feb 2 '06 #10

P: n/a
On Tue, 31 Jan 2006 21:11:45 +0000 (UTC), ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:

<snip>
One option to consider is to do the development on Windows but using
a Unix emulation library such as MingW or AT&T's UWIN; once that code
was working, taking the -source- to a Unix system and rebuilding would
usually be within a reasonable amount of work. <snip>


Cygwin. MingW is GCC on the M$ (runtime) library plus only the patches
needed for conformance as C but not (full) Unix.

Though, if you limit yourself to Standard C, you can port from either
MSVC (carefully ignoring all the tempting extensions) or mingw to Unix
or vice versa. You can even add easily <OFFTOPIC> the portion of
Winsock that is almost nearly compatible with Berkeley sockets </>.

- David.Thompson1 at worldnet.att.net
Feb 13 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.