Solved

c lynux to c windows program

Posted on 2004-04-08
9
825 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 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