Solved

c lynux to c windows program

Posted on 2004-04-08
9
822 Views
Last Modified: 2008-01-16
Hi


I have write a program in c on linux platform i want convert the same into vc++ code in windows there are many header files i have used which are not found in vc++ here is a list of them.

#include<stdio.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<fcntl.h>
#include<time.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#define MAX_LINES 100
#include<sys/signal.h>
#include<sys/wait.h>
#include<sys/select.h>
#include<sys/time.h>

pls tell me which are the equivalent header files available in vc++

its Urgent
0
Comment
Question by:leork2004
9 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10784104
Are u compelled to use VC++
I asked this because u can use the same code (from linux) on Windows if u use a Linux based compiler for Windows

Have a look at this one for a free compiler/editor/tools

http://www.bloodshed.net/


Amit
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10784151
Also,
the system calls u used in your Linux code may not be avaibale on Windows OR may be available with some different name/parameters with some other header files

Have a look at this link for the sys/socket.h      header  file specifically
http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20568936.html?query=Unix+Header+files+in+Windows&searchType=topic


So u would have to check thru your code if u are using Unix/Linux specific code

Amit
0
 
LVL 10

Accepted Solution

by:
Sys_Prog earned 168 total points
ID: 10784166
Code is portble if u do not system specific system calls

#include<sys/types.h>
#include<fcntl.h>
#include<sys/signal.h>
#include<sys/wait.h>

all seem to be quite Unix/Linux specific.......tough to find the VC++ version...

Amit
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Assisted Solution

by:wayside
wayside earned 166 total points
ID: 10784321
These:
#include<stdio.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<time.h>

are all in the main include directory for the compiler (D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include on my machine).

These two are probably replaced by winsock2.h:

#include<sys/socket.h>
#include<sys/select.h>

This one is not in the sys subdirectory, so take off the "sys/":
#include<sys/signal.h>

These don't exist on my system. Your best bet is to look up each function you are using out of these in MSDN, that will tell you which include file to use. If the function doesn't exist, then your porting gets much more interesting. :)

#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/wait.h>
#include<sys/time.h>
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
ID: 10784535
Usually, you'd start with sth. like

#ifndef WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#else
#include <winsock.h>
#endif

For a bigger part of your code that deals with system mechanisms like 'wait.h' and/or 'signal.h', check out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Port_From_UNIX_To_Win32.asp ("Port from UNIX to Win32")
http://msdn.microsoft.com/library/en-us/dnucmg/html/ucmglp.asp ("UNIX Application Migration Guide") with http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch09.asp ("Chapter 9: Win32 Code Conversion") in particular.
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10784603
Hi Sys_Prog,

Yes, bloodshed is nice...

Or try cygwin: http://www.cygwin.com

Maybe also Mingw, but it might be not enough for you.

Cheers,
Stefan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now