LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-05-2007, 04:45 AM   #1
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Rep: Reputation: 0
Question Need help regarding porting a project from windows to linux


Hi all
I am assigned a task which is to port a windows project into linux. I am relatively new to the porting concept. However I find this as interesting. But to my wonder I don’t see much discussion or help on porting at web and forums. Usually people try to port an application to linux by using WINE but I think that it is not actual porting of the application but instead we are running a windows executable inside linux process through some virtual layer… but that is not porting as much as I have understood. Also to write a portable code is not as difficult as to try to port an existing Windows specific application code into the linux platform.
I have a windows application/project built in C/C++ using windows API and MFC at some spots. Now the application need to be ported to Linux. I want to understand that are there any rules & guidelines specific to the porting. Currently I have situation somewhat like this:
Application has a MS COM Component depending on various libraries present in the shape of DLLs.
This COM (Component Object Model) serves the basic and fundamental logic of the application. But it uses several other 3rd party libraries and some self built libraries present in the form of DLL. Some of these DLLs are using MFC library.

Can any body suggest me that what formula I shall apply and follow any theory of porting in my situation. Currently I am planning to try to convert all the DLLs in a Linux Dynamic shared library and exclude all the MFC/Win API specific part from the code(that can be analyzed later). But What I have confliction is that is there any replacement of MS COM technology in Linux or I have to convert that COM into the Shared Library as well such that a separate process is forked in linux which contain a shared object or some thing like that. I really need the expert programmers guidance and any kind of information will be appreciated.
Regards
 
Old 12-05-2007, 06:40 AM   #2
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
I believe you have already posted this, only yesterday, please see here.
 
Old 12-05-2007, 06:49 AM   #3
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Original Poster
Rep: Reputation: 0
yes I did post but didnt have any response yet............... got in haste and thus posted a complete thread!
 
Old 12-05-2007, 07:24 AM   #4
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
Hi Noble,
I see, sorry for destroying your "zero reply thread" opportunity, and yes your mistake was in piggybacking the other thread rather than making one of your own, which again didn't give you the zero reply exposure that might have helped.
Quote:
I am assigned a task which is to port a windows project into linux
I am curious if this is a work or academic assignment? If the former, then it seems pretty heavyweight for what I perceive as your level of experience (not a criticism). I confess to not having a clue, but realise it to be a very complex area. Mathewg42 in the other thread gave some advice, but it may not be relevant to your situation. I am presuming that you have access to the source code, so can only really suggest that you need to understand what the program is doing and how. Replacing functionality and library calls with similar functionality in your chosen language. This is not difficult to achieve for very small programs, but feel that it will quickly prove to me a massive undertaking that will quickly overwhelm you. It strikes me that I am not porting but re-writing the program, which is not what you want.
What I can hope for is that someone can point you at a couple of guides about how to start out considering what is needed to port programs and larger applications/projects and the issues you might need to address along the way.
I suspect that if you had asked a much shorter question that you might have got a useful answer much faster.
Good luck.
 
Old 12-05-2007, 05:05 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
It's probably(!) going to be simpler to spec what the prog does and then write it from scratch in Linux mode as it were, rather than trying to 'port' it line by line or fn by fn.
Although MS and Linux perform similarly on the surface ie from the user's pt of view, they are radically different underneath.
You might want to look at the Qt and gtk libs.
Maybe you'll get lucky and someone who's done this before will comment.
 
Old 12-05-2007, 11:59 PM   #6
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Original Poster
Rep: Reputation: 0
THNX PAix and chrism01

Quote:
I am curious if this is a work or academic assignment? If the former, then it seems pretty heavyweight for what I perceive as your level of experience (not a criticism).
Well Yes my level of experience is at academic level and I welcome any criticism. More info about project nature is... that there is software component (a project itself) developed in windows and what it does is that it converts a document(this document is kind of a report that contains images, text and any printable DATA) into another defined format(this format is company's own format). All the logic to convert into this format is written in this component but now if the same logic is tried to be rewritten in Linux that will consume a large time so the company want to use the concept of reusability and porting methodology.
I have taken this project because going through this project will be a great learning experience as I will have to study both OS under the hood. However I have learnt now that it is really a JOB man to understand the code done by someone else and left without documentation.
Quote:
Maybe you'll get lucky and someone who's done this before will comment.
That I pray....
Do keep help new babies like me

Regards
 
Old 12-06-2007, 12:29 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Reusability is more like libraries /modules being re-used for different progs, BUT in the same env.
Portability is moving to a differnet env.
It it had been eg Perl, it would have been fairly simple UNLESS you used MS specific modules to do some stuff.
Similarly with ANSI C.
Your desc sounds as though the prog was written purely natively ie with no intention of porting. This is normal, but it does mean (imho) that a re-write is needed, but you do have (presumably) the knowledge of what the prog has to do (from the user's pt of view) and the src code.
I hope you are a good programmer and it's a short prog. The orig company should have some docs, if only a spec. How many lines of code is it and are there any comments.
An option you might consider running a virtual MS env on Linux and run the prog in it, unless porting is the point of the exercise...
 
Old 12-06-2007, 01:23 AM   #8
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Original Poster
Rep: Reputation: 0
well project is not short but instead it is a complete product that was written 27 years before in pure C and then within these years C++ was also added and then GUI was added ... when MFC and COM emerged those were also added and as now there is demand for Linux from customers so company want to do this too. This is the one reason that technical documentation was not maintained efficiently and instead company relied on mentoring process... But as now it is totally different OS and thus to run this huge software on VM is difficult because this will require more resources as Software uses so much memory and it has also client-server features.
But as it is complex task to completely port this product .. the company guys decided to do port small components first.
For this I am trying to port... but I really get irritated when I find libraries being used specifically for windows and There comes lot of stuff that I then have to study and ask .
However I think that there shall be porting methodologies and principles.... Does any one agree with me or it is only my temporary illusion.
 
Old 12-06-2007, 05:24 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, there may be std type replacements eg if using MS COM obj, use this (for some value of 'this') as a replacement technique.
Given the long and tortuous history/mix of tech in the orig prog, I'd be surprised if it would that easy, as any particular technique affects the overall design/arch of the prog. If you try to replace each bit dependent on whether it was done in C, C++, COM etc, you'll still end up with an unmaintainable prog because the Linux replacements have a different idea about how the world works.

Not sure if that's clear as mud.. hmmm try this; what I'm trying to say is piecemeal replacement may 'work', but a much more sane/clean result would be if you made it work the way the Linux tech works, rather than shoehorning in gobs of 'translated' MS.

As an example, during the Y2K proj we needed to translate some FORTRAN to C, and initially did it with an auto translater, but the code was horrible and I had to amend some anyway (for Y2K) and in the end it would have been better code and probably quicker if I'd coded myself in C from scratch, just usng the functionality spec.

I'd still like to hear from anyone who's done this; I could be way off.

If you do decide on a rewrite, it's worth looking at using a different lang that would make your life easier.
Personally, I did about 8yrs of C, now about 8yrs of Perl.
It's about 90% as fast as C, but programmer productivity is faster because it does the fiddly stuff for you eg vars are dynamically sized, so no worrying about going off the end of strings etc. There's a huge lib of pre-written modules here: search.cpan.org. Basic var types are scalar, array, hash. Full lang man inc examples here: http://perldoc.perl.org/index.html

Other langs are avail, but I don't know enough about them to comment (others will). I can say I've been very happy with moving up to Perl, even though I liked C once i got the hang of it.

Looking fwd to other's comments.

Last edited by chrism01; 12-08-2007 at 06:17 PM.
 
Old 12-07-2007, 06:58 AM   #10
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
First thought- Have you tried running your application using WINE? WINE is not a virtualization layer, but rather an independent implementation of the Windows API. Applications that I have used under WINE do not suffer any performance penalty. Problems only arise from incomplete implementation of the Windows API.

Second thought- If you have existing DLLs, then creating a winelib application is the only method that I know of that can use these in a native linux application.

Final thought- I am only a hobbyist programmer, but I have written a winelib application that makes use of Windows DLLs. The application was written in C so that I could compile using the WINE C library. I spent some time trying to get STLport to compile against the WINE C library, to enable C++ ( as I had a model program written in C++ to work off), but I was not successful.

Just some random and probably best ignored thoughts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux to windows porting Atrocity Linux - Software 5 02-19-2013 08:36 AM
Porting C++ code from windows to Linux ashwinipahuja Programming 9 06-03-2004 02:09 AM
Porting C++ code from windows to Linux ashwinipahuja Linux - General 1 03-22-2004 02:57 AM
Porting C++ Project from Windows to Linux?? ashwinipahuja Programming 0 03-20-2004 01:12 AM
porting windows ce code to linux rainmann Programming 7 06-12-2003 07:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration