LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-08-2007, 04:51 PM   #1
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Rep: Reputation: 30
Cross-Platform Programming


Hello,

How easy is it to program for other platforms from another? For instance, could I write Windows programs in Linux or BSD Unix? How about for MAC OS X? Could I write a Linux program in BSD Unix, or vice versa?
 
Old 03-08-2007, 05:40 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
You could start by reading an article on wikipedia about cross-platform programming here. Basically, it will heavily depend what kind of programs you are doing, what language you are using and things like this.

Or you could use the good old Java ^_^;;
 
Old 03-08-2007, 10:42 PM   #3
stairwayoflight
Member
 
Registered: Apr 2006
Posts: 59

Rep: Reputation: 15
easy programming?

Hi,

It is actually really easy to program for windows/bsd/linux from one of the others.. they all provide ide's and text editors inside which you may write code. But you mean generating executable's, thats another story.

One thing to consider is your interest in programming, do you wish to learn? You may find an OS like linux will be not only fun to learn, but it will tend to push you towards doing new things with your computer, possibly due to the generally different culture of its users. It tends to be more of a "how to" culture than windows, a world where people tend to pay for (or steal) software to do certain things rather than harness the power of free software, although thats not always the case.

All that to say, linux & the bsd's tend to be more programmer oriented. Its worth taking the plunge.

Specifically about programming, most programs you will begin to write will not be "in bsd" or "in linux," but will be aware of their own data and interaction with the user. The program interacts with the os through "system calls," basically handling stuff like user input, output to screen, writing to the disks and using the network. In C, printf() will work in a program on bsd, windows, whatever, as long as the stdio.h library is implemented. So the idea is that the library implements the printf() function differently on different platforms, but it is called the same way whether its a windows or unix console app. However not all libraries are implemented on all platforms. Allegro is a game programming library that is very portable (C, C++). Compiling is another issue, a cross compiler will have to be set up properly to generate code for the other platform.

Lisp, python, and java are examples of languages that don't need to be compiled to "native binary"--this is to make their use more universal. There are lots of good tutorials on these languages. Another consideration is web programming, a la the idea of programs interacting with the user over the internet. You can get exactly the same web interface on different os's, while running the program itself on the platform you want.
 
Old 03-09-2007, 11:06 AM   #4
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

I can sort of see how you could write the code for another platform, but how would you test it. Even if you could compile it with a cross compiler (please tell me more about these), how would you test and debug it?

As far as languages, I am more interested in the traditional languages like C/C++, ADA, Assembly, etc. I don't think I would like to use Lisp (I don't like EMACS) or JAVA, which has never impressed me and at times annoyed me from a user standpoint.

My experience in programming is limited. I learned Pascal via TurboPascal 7 in high school and a class in Visual Basic in college, which didn't teach me anything but how to fumble through a very sloppy program - oh, and I wrote the 'hello, world' program in C. But I am eager to learn much more! I am already familiar with Linux and a little bit with BSD Unix. I was raised with Windows so I know that OS. I am fairly knowledgable in networking and know how to build a computer from scratch (and repair them, too). But I feel incomplete and lacking without programming skills.
 
Old 03-09-2007, 12:06 PM   #5
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
When I have to write a cross-platform app that has to work with Windows, or requires a GUI, I use the QT toolkit. QT is a cross-platform C++ library (there are bindings so you can use other languages with it as well). QT handles networking, file i/o, gui stuff, ect. so you don't have to deal with writing special code for Windows vs. strict POSIX OS's.

If I'm writing a non-gui app that doesn't need to run on Windows (which is usually the case for me) then I just use the normal unix-c stuff.

As far as testing is concerned, with QT you can test on any platform it supports, but ultimately you will probably want to do final testing on all platforms you intend your program to run on.
 
Old 03-10-2007, 02:04 PM   #6
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
JMJ, the higher-level language you use, the easier it will be to go cross-platform, but the less direct control you'll typically have over your hardware and operating system.

Sounds like you want to learn more C. C is most often used for writing drivers and low-level libraries used by other programs.

If you're interested in networking, you might check out W. Richard Steven's books about TCP/IP. Also look into what POSIX means.

Note that C, networking drivers, and POSIX, are some typical staples for hardcore cross-platform unix hacking.

Last edited by johnMG; 03-10-2007 at 02:05 PM.
 
Old 03-10-2007, 04:01 PM   #7
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by JMJ_coder
I don't think I would like to use Lisp (I don't like EMACS)...
Lisp doesn't have anything to do with Emacs except that Emacs is written in Lisp. That's a one-way association, there. Many people write Lisp in an editor other than Emacs; you could use Vim or jEdit or any other text editor. And actually, that one-way association is verly loose at the user level, because you can use a lot of Emacs' features without understanding an ounce of Lisp code. But to automatically dismiss Lisp because you don't like Emacs -- well, that's like saying I don't want to learn C because I don't like Windows.
 
Old 03-11-2007, 12:59 PM   #8
stairwayoflight
Member
 
Registered: Apr 2006
Posts: 59

Rep: Reputation: 15
Quote:
Originally Posted by JMJ_coder
I can sort of see how you could write the code for another platform, but how would you test it.
You could use virtualization to test your binaries inside the host operating system, eg. vmware server. On linux you can run windows and bsd guest os's for example. Pearpc allows you to run os x. But it would still be worth it to test it out on the os running on real hardware eventually, I believe most virtualization softwares give you a somewhat generic hardware profile, eg. the os may *think* its using a 3com network card when the real hardware is different. Some bugs may only expose themselves with certain hardware and drivers. If you decide to code in higher level languages than C it may be less of an issue.
 
  


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 Cross-Platform "C" Programming tux_addicted Programming 10 04-28-2006 03:50 AM
LXer: Book Review: Cross platform GUI programming with wxWidgets LXer Syndicated Linux News 2 12-21-2005 12:52 PM
Good resources for cross-platform Qt/ KDevelop programming TemplaraPheonix Programming 1 12-19-2005 09:03 PM
Open source interface designer for windows for cross platform programming? dr_zayus69 Programming 1 05-15-2005 07:34 AM
Cross Platform c++ gui programming djadhav Programming 8 05-25-2004 02:15 AM

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

All times are GMT -5. The time now is 08:04 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