473,385 Members | 1,673 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,385 software developers and data experts.

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

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

Oct 25 '06 #1
7 11179

Vi*******@gmail.com wrote:
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/

Oct 25 '06 #2
In article <11*********************@h48g2000cwc.googlegroups. com>,
<Vi*******@gmail.comwrote:
>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.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Oct 25 '06 #3
Vi*******@gmail.com writes:
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.

--
Ben.
Oct 25 '06 #4
Vi*******@gmail.com wrote:
>
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.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

Oct 25 '06 #5
On 24 Oct 2006 17:53:31 -0700,
Vi*******@gmail.com <Vi*******@gmail.comwrote
in Msg. <11*********************@h48g2000cwc.googlegroups. com>
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
Oct 25 '06 #6
In article <4q************@individual.net>,
Robert Latest <bo*******@yahoo.comwrote:
>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. :(
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Oct 25 '06 #7

<Vi*******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
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...

Thanks

Oct 28 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jhuola Hoptire | last post by:
Just installed J2RE 1.4.2 on a Linux server. I am very knew to the POSIX world. I couldn't dig-up much in the docs or via google about the following: 1 - Is there a standard way to make sure...
12
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I...
2
by: christos panagiotou | last post by:
hi all I am trying to open some .raw files that represent images (256x256, 8 bit per pixel, no header) in a c++ program I cannot copy paste the module here as it uses a method from the VTK...
23
by: Rudolf Bargholz | last post by:
Hi, I have a ralatively simple SQL: select FK from TABLE where upper(A) like 'B%' and upper(C) like 'D%' We have DB2 UDB v7.1 FP 12 installed on Linux and on Windows 2003 On Linux using...
57
by: B.r.a.d.l.e.y | last post by:
A client has moved a back-end data file to a Linux machine instead of Windows. It now will only let one user log in at a time and gives some sort of "admin file not found" error. My first...
2
by: Andrej Litowka | last post by:
Hi All! If anybody know, how I cann set an enviroment variable (with ANSI C) on Windows similar like on Linux. I tried setenv, but the function doesn't work correct on Windows - it sets env....
27
by: Mike | last post by:
Open source programs in general suck pretty bad also. Here are some loose facts regarding why projects like Linux, PHP, MYSQL, and other open source programs suck: - Linux is simply a clone of...
6
by: JaxDawg | last post by:
OK... Crazy (possibly dumb) question here... I have a site running apache, mysql, php in a Win2K environment. Primary development is that env also. I also am setting up a linux box (old laptop),...
4
by: peter | last post by:
I've come across a weird difference between the behaviour of the Tkinter checkbox in Windows and Linux. The issue became apparent in some code I wrote to display an image in a fixed size canvas...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.