Solved

c lynux to c windows program

Posted on 2004-04-08
9
828 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
Industry Leaders: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

739 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