C in Linux vs C in Windows, is there any difference?

V

VijaKhara

Hi,

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

Thanks
 
D

Dr_Locke_Z2A

Hi,

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

Thanks

It really depends on the program. If it uses a bunch of libraries that
are *nix only then you have your work cut out for you. There is,
however, a program called Cygwin that compiles linux code on Windows,
and it might allow you to compile it under Windows without changing a
line of code, so you may want to check that out at
http://www.cygwin.com/
 
W

Walter Roberson

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

You are likely encountering a combination of several different
*kinds* of errors:

- the author may have written assuming the C95 or C99 standard, but
your Windows compiler likely does not support anything past C89

- the author may have used nonstandard extensions to the C language
itself that were supported on his compiler but are not supported
on yours

- the author may have assumed that an 'int' or a 'long' were
particular sizes different than what your compiler uses; this
can lead to some obvious compilation problems, but can also lead to
some difficult to find bugs

- the author very likely used linux (or more generally, Unix or POSIX)
operating system or library calls (and their associated header files)
to do things that are either done completely differently on Windows
or else are not possible at all on Windows


For the first three kinds of errors, you have a chance that, if you
plug away at the problem long enough, that you could rewrite the
code to conform to accepted portable C standards.

However, if system specific extensions were used, then possibly the
only way to implement those extensions would be to rewrite Windows
itself (or at the very least to write some new Windows device driver.)

We would have to have a look at the code in order to determine
the feasibility of making it work in Windows. (Don't post it!
At -most- post a URL of where we might find it.)


If you are fortunate, then possibly all you need to do is build
the source under MinGW; see www.mingw.org for more information about that.


In this newsgroup, we can help to try to find fully standard ways of
writing specific reasonably-small bits of code (if we can figure out
what the author meant by them), but the people in this newsgroup
often do not know the little fiddly details about Windows or about Linux,
and we are qualified (or interested) here in taking something system-
specific about one operating system and indicating what the
corresponding system-specific bit is for a different operating system.
We're the *portable* code department here -- portable in the sense
of assuming that *only* what is in the C standard is available;
for anything that is Linux or Windows specific, we refer people to
other newsgroups.
 
B

Ben Bacarisse

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

There need not be, but you obviously have to change *something*.

C is has a long history and has been around in various flavours, often
with compiler-specific extensions, but, importantly, it has been
standardised by the ISO. As a result it is possible to write C that
will compile and run as expected on a very wide range of machines and
systems with either no change at all or a few changes to isolated and
clearly identified system specific parts.

It is also possible to write non-standard C that makes all kinds of
assumptions about the compiler and the environment the program will
execute in -- all distributed liberally about whole source. Which kind
you have (or something in between) will determine the amount of work
ahead.

Post code with error messages and the folks here can say more.

You may need simply need to tell your compiler to use a specific C
standard or you may simply be missing a library that the program
depends on but more info is required.
 
C

CBFalconer

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

If the code is portable ISO standard, no. However my crystal ball
tells me the code isn't. You could install the DJGPP system and
compile your code with "gcc -W -Wall -ansi -pedantic" to see.
 
R

Robert Latest

On 24 Oct 2006 17:53:31 -0700,
in Msg. said:
I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

You have already gotten an exhaustive collection of good hints.
What it boils down to is this: If the program is a command-line
tool, working in "text mode" only, it will probably be very easy to
adapt.

If, on the other hand, the program uses GUI features, things will
probably be difficult.

robert
 
W

Walter Roberson

Robert Latest said:
You have already gotten an exhaustive collection of good hints.
What it boils down to is this: If the program is a command-line
tool, working in "text mode" only, it will probably be very easy to
adapt.

Not if it uses networking or shared memory or kernel measurements
or any of the -many- other features that differ greatly between Windows
and Unix. :(
 
D

David Wade

Hi,

I am given source codes written using C. The writer told me that he
wrote on Linux. Now I am trying to compile and run it on Windows. There
are many errors shown up. Are there any configurations or any chances
in the source codes I need to get done before compiling it on Windows?

It depends on why you want to move it to Windows. If its for personal use
then you may be able to get it to run using Mingw or CYGWIN. If you want a
"native port", compiled with say Microsoft VC then you may have to fix the
incompatabilies in the code...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top