LinuxQuestions.org
Review your favorite Linux distribution.
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 10-18-2010, 03:41 PM   #1
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Rep: Reputation: 0
Ncurses based program had to be recompiled on a different PC, same OS


Riddle me this:

On an Ubuntu Server I am running, I wrote a small Ncurses program in GCC. It worked just fine.

Then, I copied the executable over to my Ubuntu 10.10 desktop edition with sftp. No matter what I did, it kept giving the error:

error opening terminal: xterm.

I had copied other non-curses programs and they all ran just fine.

Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?
 
Old 10-18-2010, 03:53 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by tardis1 View Post
Riddle me this:

On an Ubuntu Server I am running, I wrote a small Ncurses program in GCC. It worked just fine.

Then, I copied the executable over to my Ubuntu 10.10 desktop edition with sftp. No matter what I did, it kept giving the error:

error opening terminal: xterm.

I had copied other non-curses programs and they all ran just fine.

Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?
Find "error opening terminal" message in source, understand the context, i.e. what the program was actually trying to do, what checks it performed, what check failed, etc., and you'll find an answer to your 'why' question.
 
Old 10-18-2010, 04:01 PM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
OK, you'd better not change case in error messages:

Code:
build/ncurses-5.7/ncurses/base/lib_initscr.c:       fprintf(stderr, "Error opening terminal: %s.\n", name);
- and now you know, which file to start from.
 
Old 10-18-2010, 09:53 PM   #4
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Original Poster
Rep: Reputation: 0
Sorry Sergei,

I'm not understanding your advice. The error message is coming from the OS. It is not something I coded in to the source. The program ran on my server where I originally compiled it. I need to know why an executable copied to another machine would refuse to work unless recompiled. The OS's are supposed to be the same. Therefore, I should be able to copy programs from one machine to another and they should run. That was true with my programs that only used stdio, but the one with ncurses functions had to be recompiled.
 
Old 10-18-2010, 10:47 PM   #5
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
tardis1 -

Quote:
Q: Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?
A: In the words of a wise philosopher:
"Ca-ca happens "

Quote:
I'm not understanding your advice
I think Sergei was chastising you for transcribing "error opening terminal" instead of cut/pasting "Error opening terminal" (capital-E), making it slightly harder for him to "grep" for the error. No biggie, and certainly nothing to do either with your question or his response.

Quote:
The OS's are supposed to be the same. Therefore, I should be able to copy programs from one machine to another and they should run.
In general, true.

But there ARE exceptions.

Google for "Error opening terminal: xterm" and you'll come up with a number of hits. For example:
http://www.osgeo.org/pipermail/grass...ch/008560.html

In this case, a dependent library caused the init_scr() failure.

Perhaps something similar happened in your case. And perhaps simply re-linking the program created a different set of dependencies, all of which were satisifed on your system. It's hard to tell.

I wouldn't lose too much sleep worrying about it, and I'd be reasonably confident that the next curses program you copied to a different PC might work just fine as-is.

IMHO...
 
Old 10-19-2010, 12:19 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by tardis1 View Post
Sorry Sergei,

... The OS's are supposed to be the same. ...
As paulsm4 has already pointed out, not necessarily the set of installed libraries is the same.
 
Old 10-19-2010, 09:51 AM   #7
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Original Poster
Rep: Reputation: 0
OK, I understand; somewhat. If terminfo is not loaded correctly a curses program cannot start. I did try loading ncurses and running the executable; yet, still received the same error. This answers my question, but will also raise others.

Thanks for ya'lls help. I might eventually learn how to post questions according to the rules.
 
  


Reply

Tags
gcc, ncurses, ubuntu


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
console-based (ncurses) SIP client stringZ Linux - Software 2 12-18-2008 01:35 AM
LXer: IPTraf, a ncurses based LAN monitor LXer Syndicated Linux News 0 08-27-2007 01:11 AM
how do i uninstall bwmon? (ncurses based) pradeepmenon777 Linux - Desktop 3 01-11-2007 05:56 AM
ncurses based mp3 player introuble Linux - Software 5 11-25-2006 06:05 PM
ncurses based programs in Slack 10.0 superandrzej Slackware 3 08-08-2004 04:58 PM


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