LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-22-2004, 02:36 AM   #1
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Question Porting C++ code from windows to Linux


Hi all,
I am working on a C++ project(No MFC), The project is running smoothly on Microsoft Visual C++ 6.0 complier. Now i want to port my project to Linux, I have loaded my project on Kdevelop IDE and i have tried to compile the project, but its giving lots of errors. does anyone has some idea of the whole porting process, wut changes fo i have to make in my code????
Regards
Ashwini
 
Old 03-22-2004, 08:41 AM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 31
It depends on what Windows-specific APIs you've used, and the nature of the app. If it's a GUI app, you'll likely have to use one of the GUI APIS available for Linux, and understand how to convert from whatever GUI API you're using in Windows to the GUI API you choose to use for Linux. Or try to use one of the OS-agnostic GUI APIs available.
 
Old 03-22-2004, 01:45 PM   #3
laceupboots
Member
 
Registered: Dec 2003
Location: Houston
Distribution: Windows Vista/ XP/ Mepis
Posts: 304

Rep: Reputation: 30
You could just recompile the source using the g++ compiler. Save your source files with .c ( I suggest you use Kate as an editor, it has the highlighting for C++ source and you can display line numbers, and it has a terminal where you can compile and debug your prg) type: g++ sourcefile.c -o new file
After debugging.
type: ./ new file
 
Old 03-29-2004, 02:17 AM   #4
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Original Poster
Rep: Reputation: 15
I have tried all this
somehow i am able to compile my project
but now i am getting sebmentation fault errors
 
Old 03-29-2004, 07:42 AM   #5
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 274

Rep: Reputation: 30
Could you be more specific about your code and the errors you encounter when compiling it? We've written quite a lot of ++ code to work under both os, and as long as you stay in ANSI C++ and make sure all os dependant code is properly #ifdef'd, it should work well.

P/S some suggestion: IMHO KDevelop should be avoided at this stage of development; use makefile instead. This makes it also easier to port the code from one *NIX to another.
 
Old 05-04-2004, 01:20 PM   #6
btexpress
Member
 
Registered: May 2004
Location: Seattle
Distribution: Fedora Core 4
Posts: 77

Rep: Reputation: 15
Similar problem

I have a similar problem. I am new with porting Windows stuff to Linux. My code has some win32 stuff in it. Does that make a difference when porting? Is there a good place to look at a good makefile sample for this purpose.

Thanks.
Biniam
 
Old 05-04-2004, 01:35 PM   #7
laceupboots
Member
 
Registered: Dec 2003
Location: Houston
Distribution: Windows Vista/ XP/ Mepis
Posts: 304

Rep: Reputation: 30
http://www.mainsoft.com/products/mainwin.html

and

http://www-1.ibm.com/servers/enable/...s/porting.html

Last edited by laceupboots; 05-04-2004 at 01:37 PM.
 
Old 05-11-2004, 02:03 PM   #8
btexpress
Member
 
Registered: May 2004
Location: Seattle
Distribution: Fedora Core 4
Posts: 77

Rep: Reputation: 15
Great resources

Thank you
 
Old 06-03-2004, 01:26 AM   #9
dima_l
LQ Newbie
 
Registered: Jun 2004
Posts: 2

Rep: Reputation: 0
Question creating Makefile

Hi!

I need to port a large project from MVSC to Linux. Does anybody know some utilities to create Makefile for Linux from Visual Studio project file? (Assuming that the source code is portable)

Thanks a lot
 
Old 06-03-2004, 02:09 AM   #10
naren
Member
 
Registered: Feb 2004
Posts: 66

Rep: Reputation: 15
_____________________________________________
I have tried all this
somehow i am able to compile my project
but now i am getting sebmentation fault errors
_____________________________________________


As far as segmentation fault is concerned u can use gdb debugger
it will tell u the exact location in the code where u r trying to access the
memory that is not accessible by u...

compilation:
g++ -g file.c


Debugging:
gdb a.out


gdb a.out

type r then the program starts running

Then u need to give the necessary input for the program... n
most probably i will show u the false code...

__________________________________________________________
Makefile:

exec:main.o abc.o
gcc -o exec main.o abc.o
main.c:main.c
gcc main.c -c
abc.o:abc.c
gcc abc.c -c

and executable formed will be 'exec'

I think this will help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Porting C++ code from XP to Linux Bondfire Programming 7 08-12-2004 03:42 PM
Porting c++ code to linux Moons Programming 3 06-03-2004 01:24 AM
Porting C++ code from windows to Linux ashwinipahuja Linux - General 1 03-22-2004 02:57 AM
porting a C++ code to redhat Linux environment KevinG Programming 12 01-02-2004 03:55 PM
porting windows ce code to linux rainmann Programming 7 06-12-2003 07:19 AM


All times are GMT -5. The time now is 12:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration