Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Porting C++ Application from Linux(g++) to Win XP (VC++ .NET 2003)

Status
Not open for further replies.

kingsree

Programmer
Oct 9, 2005
5
0
0
US
Hello all,

I'm a newbie to this group. I'm currently working on a project where the task is to port an entire C++ application from Linux (g++) to Windows Xp (Visual Studio 2003).

I'm looking for tips regarding how I should start doing this. What would be the major changes that I would need to make? Any tips would be hugely welcome.

I'm also new Visual Studio Environment. So it would be great if anyone could suggest how I should start proceeding with it.

Thanks
Srinath
 
Which version of gcc/g++ are you porting from: is it the C89 standard or the C99 standard. VC++ is C89. If you are not using the new C99 features like dynamic arrays on the stack and macros with variable parameters, it should port quite cleanly.

A few nasties that may take a bit of time
1)The following may cause an error
Code:
for (int x = 0; i < 10; i++) {}
for (int x = 0; i < 10; i++) {}
In VC++, the int declaration is global in a for loop. There may be a switch for this.
2) Make sure the lines are terminated with CRLF. Unix just uses LF. Mixtures of LF and CRLF can cause lines of code to be missed out and can completely mess up a debugging session.
3) A backslash \ at the end of a comment takes the next line as a comment.
4) TCHARs are 2 bytes: not 4 bytes. On Solaris at least, they are 4 bytes. Not sure about Linux.
5) The comms library (sockets etc) isn't a full implementation. Some things are missing but I can't remember what.
6) Shared memory interface is completely different. It has to be locked, read/modified and then unlocked.
7) Threads are completely different.
8) Shared libs need either a dll_export or dll_import or the exported symbols need to go into a .def file.
9) The message queue interface is different.

That's all I can think of on a Sunday afternoon - there may be more.
 
Hi All,

Thank you xwb for your tips. I guess I should give more info. about my application.

It's a console based application. I want to maintain the project in both sets of platforms.

It's an application project, not a system level project. The code doesn't have any OS specific tasks, except of course location of files and directories.

I have a couple of questions.

1. The application runs perfectly fine in unix now. Essentially there are around 25 .cpp files and the Makefile contains all info. about the dependencies and how they should be run. There is also a config directory that contains a set of config files used by the application?
My question is how should I go about porting this in VC++. Specifically How should I configure the dependencies like in the Makefile. Also How do I go about using the config files? I'm new to .NET IDE and hence I need some guidance regarding this.

2. Also for the above project, what sort of VC++ template should I use? Should it be Win32 Console Project? I'm totally lost as I have worked only in unix environment before for c++ programming. kindly help me out.

3. I also want to maintain the project in both platforms.

looking for some tips. Also suggest me some good book for learning about .NET IDE and VC++.

Thanks
Kingsree
 
1. Create a solution and then a VC++ console project. Select the one without precompiled headers. Dump all your files in that project. VC++ will work out the dependencies for you. Click F5, it will compile and run. Under project properties, there is a tick box that you can check to get it to generate makefiles for you.

There are 2 modes: debug and release. Debug does the g++ equivalent of -g. Under the directory where you have created your project, you will see 2 further directories: debug and release. The .exe files are the executables that you can copy to your configuration directory.

To run in debug mode, right click on the project in the Solution Explorer (Alt 0 if it isn't showing) and select Properties... 2nd line down in the grid is Debugging. Fill in your runtime parameters and directory there.


2. Yes VC++ Win32 console project.

Note that there is also a command line interface that you can use for building programs.

Develop your progs on Unix and then send them to VC++. Don't do it the other way round. Windows isn't fussy about filenames: Fred.cpp is the same as FRED.cpp.

Some C++ projects on Unix use .C for C++. If yours is one of those, VC++ will take your files as C files. Look for the switch that says compile C as C++ if that is the case. Look at the Advanced tab in C++ compiler settings. Make sure the /Tp flag is set.

.net is basically CORBA (DCOM) using HTTP tunnelling/SOAP. In a sentence, wrap your stuff in XML and send it through port 80. It is unnecessarily complicated in that it is scaleable so modules can run on any machine: they communicate using SOAP. Also the applications don't like it when the network cables are unplugged after they've started, even though they are not using anything outside the network. If you want to keep things simple, don't go down there.
 
Hello XWB,

A big Thank You for all the tips. Infact they are more than tips. A big thanks. I will get started on it.

Thanks
Sri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top