Solved

c lynux to c windows program

Posted on 2004-04-08
9
819 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Assisted Solution

by:wayside
wayside earned 166 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

762 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

12 Experts available now in Live!

Get 1:1 Help Now