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 12-21-2006, 03:03 AM   #1
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
Portability Linux/BSD/Windows


I wish to create a program that will be portable across Linux/BSD and Windows. My workstation runs Linux (Debian) but I also have a small Windows XP partition specifically for this purpose. I want to know how I can be sure that a cirtain function available in Linux will also be available in Windows [and do the same thing, etc.] without having to write the code in Linux, reboot into Windows, try to compile etc. I have very little experience with Windows programming.

Also.. I need my program to look "something like" the irssi window. [simpler, but I need "user input" to have a specific place on the screen, same for program output ; the program runs in interactive mode]. Is there any portable way to achieve this [a portable lib etc.].
 
Old 12-21-2006, 03:33 AM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
The easiest way is to use a portable language such as Java or Python, taking care that you use only portable functions. These languages have a portable layer that is guaranteed to work on every implementation.

For your target platforms, verify which versions are available of the chosen language, and stick to the minimum level.

BTW, I heard that Java on BSD is tricky license-wise, so something like Python is maybe more appropriate.
 
Old 12-21-2006, 04:02 AM   #3
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Original Poster
Rep: Reputation: 31
I forgot to mention that I'm coding this in C.
 
Old 12-21-2006, 04:08 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could write a console program that uses only standard C functions. You could also look into wxWidgets. It is an open source C++ API for GUI applications that will run on anything from Linux, Windows, WindowsCE, Mac OS X, even on OS/2, a smartphone or a Palm Pilot. You can also install language bindings for Python, Perl, wxBasic, javascript, java, ruby, C# and others.
 
Old 12-21-2006, 05:33 AM   #5
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Original Poster
Rep: Reputation: 31
I was thinking of using ncurses + cgywin [is this possible?]. This is what I'd like the user interface to look like:http://img208.imageshack.us/img208/6021/imgtg6.png. Is ncurses the right tool for this job?
 
Old 12-21-2006, 08:09 AM   #6
xlinuks
Member
 
Registered: Jan 2006
Location: White House
Distribution: Ubuntu 8.10
Posts: 39

Rep: Reputation: 15
Since Sun is actively GPLing Java SE I doubt this should be a problem installing it on BSD. Also, there are other Java distributions, like blackdown www.blackdown.org

Last edited by xlinuks; 12-21-2006 at 08:10 AM.
 
Old 12-21-2006, 08:37 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
type fix

Your interface could be simply use the tput command. The tput command is supplied by the nnurses package.

Cygwin and ncurses may have licensing problems that you may want to study before distributing your program.

Last edited by jschiwal; 12-21-2006 at 05:27 PM.
 
Old 12-21-2006, 08:48 AM   #8
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Original Poster
Rep: Reputation: 31
Quote:
Cygwin and ncurses may have licensing problems
I can't really find these problems. Could you give a few examples?

Using tput sounds terribly inefficient.
 
Old 12-21-2006, 09:28 AM   #9
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Quote:
Originally Posted by xlinuks
Since Sun is actively GPLing Java SE I doubt this should be a problem installing it on BSD.
You should be aware that GPL and BSD tend to avoid each other. The BSDs have their own licence and often have a problem with the GPL. Nevertheless, there ara Sun Java binaries for FreeBSD. Java is not officially supported on OpenBSD. I don't know about NetBSD.

To introuble: is C a must?

There are some libraries for C that create a "portable" environment for C: I remember that Mozilla uses one, Qt has portable functions beyond graphics as well, and others exist. But none of these solutions are as easy as using a language designed for portability and which has a large library, such as Python.
 
Old 12-21-2006, 09:55 AM   #10
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Original Poster
Rep: Reputation: 31
C is a must. It being a console application is a must.
 
Old 12-21-2006, 02:57 PM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
This is the ncurses faq that kind of scared me a bit:
http://dickey.his.com/ncurses/ncurses.faq.html

However looking at the docs in /usr/share/doc/ncurses/, I don't see any problem. Read the license info for the cygwin port to make sure. Maybe this author is off base, I don't know. (I can't imagine Eric Raymond releasing an evil eula, but Mad Dog might disagree.)

Last edited by jschiwal; 12-21-2006 at 02:58 PM.
 
Old 12-21-2006, 04:04 PM   #12
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by uselpa
You should be aware that GPL and BSD tend to avoid each other. The BSDs have their own licence and often have a problem with the GPL.
Java SE is released under a dual (or triple) license, GPL, CDDL and commercial.
Unlike GPL, CDDL is not viral and is certainly compatible with BSD requirements.
 
Old 12-21-2006, 05:10 PM   #13
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by uselpa
You should be aware that GPL and BSD tend to avoid each other. The BSDs have their own licence and often have a problem with the GPL.
While it's true that GPL code is kept out of the kernel source (and most of the system binaries), you can get any GNU code you want from Ports / pkgsrc. I use lots of GNU software, some of it absolutely essential (Bash and Emacs for two).

Your statement comes off that BSD systems don't have GPL software on them, or that they are somehow fundamentally opposed to one another, which is simply not true. And I don't think many working on the BSD system have a "problem" with the GPL, it's just not the license they're working under. Heck, a lot of GNU software gets used to build a BSD system, like ... umm ... GCC?

No hard feelings; I like 'em both!
 
Old 12-21-2006, 05:54 PM   #14
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Rereading the link I gave above, it doesn't seem to be a problem unless you compile and distribute a propriety application using the cygwin dll. Especially if you modified it. Then you must supply the source code. This is more about using Cygwin and the GPL then using ncurses. I hope I didn't alarm you too much.

I don't know what your application actually does, but you could use the ncurses library with C or python or use ncurses tput command in a bash script. It may be easier for other users if they only needed to install ncurses when using cygwin or cygwin/X, if your app where a simple bash script. ( I have nothing against python or perl here at all. ) You also wouldn't need to use the gcc ming compiler if you wrote a script. Also, since you are only distributing your own script you have less worry about whether you are violating a license due to the use of a dll You are just supplying a script ( which is in itself open source code, neat! ).

Interpreted scripts and programs are also the most portable across many platforms. A python script, for example, would require that python be installed, but it wouldn't require installing Cygwin. A bash script would require a Cygwin installation, but you might be doing the end user a favour eventually. ( All of those text utilities like sed, awk, cut, sort, latex, ps2pdf, etc. that could allow to do things in a couple 3 line scripts that they might have installed a bulky GUI application to do in the past. )

Last edited by jschiwal; 12-21-2006 at 11:51 PM.
 
Old 12-22-2006, 12:50 AM   #15
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Original Poster
Rep: Reputation: 31
The application involves Network Programming + a home made protocol; amongst other things. If Python was [during my last posts] a somewhat possible option.. shell scripts were (are) definitely out. I need speed, and others, that BASH scripting can not give me.

I said "during my last posts" because I've decided to give Python a shot after all; but I think C would have done the job nicely as well. (irssi seems to be a success story in this sense; though I don't know through how much hassle the developers went.)

Thanks for all the replies!
 
  


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
Mono code portability to Windows lant Programming 1 11-24-2005 01:49 AM
Help with multiple windows/linux/bsd installs ggutierrez Linux - General 3 12-06-2004 03:11 PM
Beginner Q : Windows/Linux apps under BSD ? Cryptor69 *BSD 1 03-23-2004 09:25 AM
c++ on BSD and linux same as windows? Vyeperman Programming 2 10-18-2003 11:13 PM
portability linux to Windows. SOS nephele101 Programming 4 06-10-2003 10:57 AM

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

All times are GMT -5. The time now is 04:19 PM.

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