Solved

c lynux to c windows program

Posted on 2004-04-08
9
827 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 39
Fast, free, private online code repository / editor 7 113
sorting efficency of sorting algorithm 30 129
gdb doesn't stop on breakpoint 2 113
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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

735 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