473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is C portable from PC to UNIX

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
10 1654

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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Henri Schomäcker | last post by:
Hi folks, I have a quite big class, which I want to use on UNIX-like systems and on win32. Until now, everything is absolutely portable. But now I need to read a directory and use the os...
6
by: Shaun Heveron | last post by:
Hi, I'm working on a portable ANSI C++ application designed to compile and execute under Windows and LINUX/UNIX. Is there a portable way of obtaining the current working directory? Sorry, if...
385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
13
by: James Harris | last post by:
Hi, Can someone recommend a book that will teach me how to approach C programming so that code is modularised, will compile for different environments (such as variations of Unix and Windows),...
2
by: sugaray | last post by:
i was just told in the 'simple base-conveter program' thread, that using 'return' is not portable in such case: if(argc!=2) { fprintf("error message\n"); return 1; } it should be replace by...
10
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to...
131
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
13
by: bwaichu | last post by:
I have written the program below to just create and populate an html file. I am running into a problem when viewing the created file in vi. I am told by vi that the file does not have an end of...
69
by: Bill Reid | last post by:
This is how I handle a check that the last character of a text file is a newline: /* checks if newline is last character of text file */ unsigned check_text_file_newline_termination(FILE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.